Need help running imagemagick command over many files
Posted: 11 Jan 2021 21:59
I want to run this code on many tiles:
convert input.jpg -resize 300 output.jpg
I had some old code that I thought worked:
The code doesn't work
Not sure what I'm doing wrong.
It just goes on a loop forever. I'm sure the code worked when I used it previously for a similar imagemagick command.
Also:
- I will run the code on jpg and png files.
When running on PNG, I need to give jpg as the output file name, like: convert input.png -resize 300 output.jpg
Else, I will get PNG output. How do I do this in the bat file?
- I want the output to be changed from 'original filename.jpg' to 'original filename optimised.jpg'
Not sure where to start with this - guessing it's related to the above?
- I want to output into a folder called 'Output'
But... want to first check if it exist. If exist, delete contents (no prompt needed). If it doesn't exist, then create and output.
Is this getting too complex for a bat file?
Any help would be appreciated.
Thanks.
convert input.jpg -resize 300 output.jpg
I had some old code that I thought worked:
Code: Select all
:loop
convert "%~1" -resize 300 "%~1.jpg"
shift
if not "%~1"=="" goto :loop
pause
Not sure what I'm doing wrong.
It just goes on a loop forever. I'm sure the code worked when I used it previously for a similar imagemagick command.
Also:
- I will run the code on jpg and png files.
When running on PNG, I need to give jpg as the output file name, like: convert input.png -resize 300 output.jpg
Else, I will get PNG output. How do I do this in the bat file?
- I want the output to be changed from 'original filename.jpg' to 'original filename optimised.jpg'
Not sure where to start with this - guessing it's related to the above?
- I want to output into a folder called 'Output'
But... want to first check if it exist. If exist, delete contents (no prompt needed). If it doesn't exist, then create and output.
Is this getting too complex for a bat file?
Any help would be appreciated.
Thanks.