Currently, My program is supposed to do the following
- Inside a for loop, check the file size of the first attachment.
- After checking file size, i will save the name of the file that it is reading.
- Do the algorithm to calculate the desired size and add KB at the back of it.
- Use ImageMagick to choose the desired path output, desired file size and input filename
for %S in Images\RAW_IMAGE\*.jpg) do set outsize=%~zS & set name=%~nxS & set /a outsize=(outsize*80/100)/1024 & set outsize=%outsize%KB & cd Images\RAW_IMAGE & mogrify -path Images\COMPRESSED_IMAGE -define jpeg:extent=%outsize% %name%
For some reason, i get this error after running it
: mogrify: unable to open image '%name%'
where it should be the file name as I've tested the code step by step for a singular file and it works.
I suspect that due to my lack of understanding of how code works in CMD, the outsize & name values are not updated.
I would appreciate it if anyone could give me some pointers on what I'm doing wrong.