0
votes

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 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...

Simply put, I would like to transform the string %originalpath%\subfolder\image1.jpg to %convertpath%\subfolder\image1.jpg

thanks,

Blaise

1

1 Answers

0
votes

There is two issues.

1) Example of working batch (e.g. "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

cmd /V:ON /c test.cmd