batch conversion from cmd line
Author
Discussion

Bodo

Original Poster:

12,601 posts

296 months

Saturday 1st January 2005
quotequote all
I want to use ImageMagick for batch file conversion; PNG format pictures to JPG.

On a single image,

bodo@bulldog:~> convert picture.png picture.jpg

works very well.

Now, when I type

bodo@bulldog:~> convert *.png <what goes here?>.jpg

"$" and "%f" don't work. Does anyone know how to do it without a shellscript?

GreenV8S

31,020 posts

314 months

Sunday 2nd January 2005
quotequote all
If you have a version of DOS with command line extensions (NT onwards I believe) you should be able to do something like:

c:> for %f in ( *.png ) do convert %f

There's also a syntax for stripping the extension off so you can replace .png with .jpg or whatever.

JamieBeeston

9,294 posts

295 months

Sunday 2nd January 2005
quotequote all
You would have to make a simple script I imagine.

You can batch convert, but It wouldnt appear to retain the filenames, so not much use.

A simple shell script will do.

Lemme know if you want me to get one of my coders to knock you (summin) up

Bodo

Original Poster:

12,601 posts

296 months

Sunday 2nd January 2005
quotequote all
Cheers, gentlemen!
I use bash on Linux, so the DOS prompt suggestion didn't work.

Jamie, thanks for the offer. I guess I'll try to research a little bit further. The manpages of ImageMagick are HUGE

JamieBeeston

9,294 posts

295 months

Sunday 2nd January 2005
quotequote all
Highly Overpaid Coder said:


#!/bin/sh
for a in `ls *.png`
do
nf=`convert $a ${a%.png}.jpg`
done;



Stick that in a bodo.sh

chmod bodo.sh +x

then just execute it in the dir with the .png files in, it will read them in and pass the relevant details to convert (assuming its pathed! if not edit the script for full convert path)

its very basic, with NO error checking.. so use at own risk blah blah.

Worked when I tested this end tho.

Enjoy.

Bodo

Original Poster:

12,601 posts

296 months

Sunday 2nd January 2005
quotequote all
JamieBeeston said:

Highly Overpaid Coder said:


#!/bin/sh
for a in `ls *.png`
do
nf=`convert $a ${a%.png}.jpg`
done;




Stick that in a bodo.sh

chmod bodo.sh +x

then just execute it in the dir with the .png files in, it will read them in and pass the relevant details to convert (assuming its pathed! if not edit the script for full convert path)

its very basic, with NO error checking.. so use at own risk blah blah.

Worked when I tested this end tho.

Enjoy.
Cheers, Jamie! Works very well

I owe you a pint

JamieBeeston

9,294 posts

295 months

Sunday 2nd January 2005
quotequote all
Bodo said:
cheers, Jamie! Works very well

I owe you a pint


Its ok, I owe my coder £40k for that

At london prices, thats about even I suppose


Glad its sorted tho.

J