Page 1 of 1

batch png to jpg drop in conversion

Posted: 2015-04-25T20:38:09-07:00
by Dread Knight
Hello!

I'm want to save up some hdd space and decided to batch convert my image collection into jpg files as quite a few of the images there are in png format.

Did some tests with the command line but I can't quite manage to replace the png images with jpg versions while also deleting the original png and having the new jpg use the same file name. Gave both convert and mogrify a go, any ideas?

Code: Select all

convert ephemeral:*.png *.jpg
This code above almost does the job with the exception of not maintaining the original file names :?

Re: batch png to jpg drop in conversion

Posted: 2015-04-25T20:59:12-07:00
by snibgo
Windows BAT syntax:

Code: Select all

convert *.png -set filename:myname %%t %%[filename:myname].jpg
Adjust for other shells (eg don't double the % in bash).

This reads all the png images into memory first, before converting any, so is memory-intensive.

Re: batch png to jpg drop in conversion

Posted: 2015-04-25T21:10:30-07:00
by Dread Knight
Thanks, though I'll need something that's not memory-intensive as my image collection is quite huge :D hence why I want to compress it... hmm

Re: batch png to jpg drop in conversion

Posted: 2015-04-25T21:35:57-07:00
by snibgo
mogrify works one file at a time:

Code: Select all

mogrify -format jpg *.png
If you want to traverse directory tree, you'll need a script.

Re: batch png to jpg drop in conversion

Posted: 2015-04-25T21:58:25-07:00
by Dread Knight
Understood, thanks.