Trying to do a Windows batch script that recursively adds a watermark, and changes its size proportionally according to the size of each image within a folder. Pretty much, this is what script should do:
1. Count the number of files inside a folder to afterwards use variable in for loop.
1a. Check image size of each image inside said folder
1b. Calculate proportional size of watermark to be added
1c. Add watermark to each
2. Repeat until every image is processed.
I am stuck in the nested FOR loop that iterates between each, file, checks its size and calculates the proportional size of the watermark to be added. I added some echoes just to check if it is correctly iterating, and one of the nested FORs is, while the other one isn't.
Here's my code.
Code: Select all
rem Count files inside folder for /f %%A in ('dir ^| find "File(s)"') do set cnt=%%A echo Number of files: %cnt% echo. rem Below cycle should read image size and store it in variable for /L %%i in (1,1,%cnt%) do ( echo iCount = %%i identify -ping -format "width=%%w\nheight=%%h" ^ IMG%%i.JPG`) do set %%J rem Calculate proportional width set /A defaultWidth=5184 set /A PropLogoWidthStep1=%width%*1003 set /A PropLogoWidth=%PropLogoWidthStep1%/%defaultWidth% rem Print variables in screen echo. echo ------------IMG %i%------------ echo Width : %width% echo Height: %height% echo Proportional Width: %PropLogoWidth% echo %%i )
Thanks so much!