I have a folder with a number of sub folders in it which contain the images I want to convert from PNG to JPEG.
I have tried:
cd d:\images
mogrify -format jpg \*\*.png
I tried slashes in both directions (I'm using Windows 7).
But I just get invalid argument
errors.
What should I do?
I'd really most value a simple example answer rather than a link to a 50 page image ImageMagick documentation if possible (I'm a newbie).
Try using the following at the cmd prompt:
mogrify -format jpg *.png
I wasted hours trying use the ImageMagick convert command in a batch file, but couldn't get it to work
You could always perform a for
-loop:
cd D:\images
for /r /d %%a in (*) do mogrify -format jpg "%%~a\*.png"
Which will run the command for every sub-folder such that it is:
mogrify -format jpg "D:\images\name of subfolder\*.png"
Which appears to meet your requirements.
To use this code in command prompt replace %%a
with %a
To use this code as it is you would need to put it in a batch-file. A very simple procedure for this is to:
All Files (*.*)
in the drop-down menu below the name.That way you don't have to open cmd every time you want to perform the action.
ImageMagick mogrify will not traverse directories. You will have to write a script loop over each directory that you want. Then in the loop change directories and run mogrify -format jpg *.png for each directory. I also recommend that you either backup your directories or use -path to set a path to your new but empty output directories.
For novice:
Download ImageMagick from below link:
https://www.imagemagick.org/script/download.php
then just copy and paste below command in cmd:
for /r /d %a in (*) do "C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe" mogrify -format png "%~a\*.jpg"
The above command is working fine for me which converts all files from JPGs to PNGs, present in the current directory.
And then if you want to remove all the residual JPGs, just hit the below command:
for /r %i in (*.jpg) do del "%i"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With