I would like to execute a program to manipulate all images in a folder and its subfolders and save these images in another directory, but in the same subfolders structure. For this I need to get the full path of both the original and the processed images.
我想执行一个程序来操作文件夹及其子文件夹中的所有图像,并将这些图像保存在另一个目录中,但是在相同的子文件夹结构中。为此,我需要获得原始图像和处理过的图像的完整路径。
But I simply can not get the SET command to transform the directory name. Here is what I do:
但我根本无法获得SET命令来转换目录名称。这是我做的:
set originalpath=g:\Users\PLAY\Documents\backuppgm\images
set convertpath=g:\Users\PLAY\Documents\backuppgm\resized
for /R %originalpath% %%G in (*.jpg) DO (
echo %%G
SET fullpath=%%G
SET modified=!fullpath:%originalpath%=%convertpath%!
echo Full: %fullpath%
echo Modified: %modified%
The idea is that fullpath would be equal to %originalpath%\subfolder\image1.jpg and that modified would be equal to %convertpath%\subfolder\image1.jpg I could then run my batch on these 2 items... But that set modified command does not work at all...
想法是完整路径将等于%originalpath%\ subfolder \ image1.jpg并且修改后将等于%convertpath%\ subfolder \ image1.jpg然后我可以在这两个项目上运行我的批处理...但是那个集合修改后的命令根本不起作用......
Simply put, I would like to transform the string %originalpath%\subfolder\image1.jpg to %convertpath%\subfolder\image1.jpg
简单地说,我想将字符串%originalpath%\ subfolder \ image1.jpg转换为%convertpath%\ subfolder \ image1.jpg
thanks,
Blaise
1 个解决方案
#1
0
There is two issues.
有两个问题。
1) Example of working batch (e.g. "test.cmd")
1)工作批处理示例(例如“test.cmd”)
@echo off
cls
set originalpath=g:\Users\PLAY\Documents\backuppgm\images
set convertpath=g:\Users\PLAY\Documents\backuppgm\resized
for /R %originalpath% %%G in (*.jpg) DO call :cvt "%%G"
goto :EOF
:cvt
echo "%~1"
SET fullpath=%~1
SET modified=!fullpath:%originalpath%=%convertpath%!
echo Full: %fullpath%
echo Modified: %modified%
goto :EOF
2) You must call it with /V:ON
2)您必须使用/ V:ON调用它
cmd /V:ON /c test.cmd
#1
0
There is two issues.
有两个问题。
1) Example of working batch (e.g. "test.cmd")
1)工作批处理示例(例如“test.cmd”)
@echo off
cls
set originalpath=g:\Users\PLAY\Documents\backuppgm\images
set convertpath=g:\Users\PLAY\Documents\backuppgm\resized
for /R %originalpath% %%G in (*.jpg) DO call :cvt "%%G"
goto :EOF
:cvt
echo "%~1"
SET fullpath=%~1
SET modified=!fullpath:%originalpath%=%convertpath%!
echo Full: %fullpath%
echo Modified: %modified%
goto :EOF
2) You must call it with /V:ON
2)您必须使用/ V:ON调用它
cmd /V:ON /c test.cmd