Page 1 of 1

change names using convert on multiple files

Posted: 2007-07-09T23:20:16-07:00
by sparkly
Hi

I'm stuck and new to this so any help is greatly appreciated. I have written a shell script to create a large number of thumbnails (png to gif). This is working but the problem is: file names are changed with the former extension added to the file name, eg. animal.png will become animal.png.gif. How do I remove the .png?

here is the script that I am using:

for img in `ls *.png`
do
convert $img -thumbnail '300x150>' thumbs/$img
done

for img in `ls thumbs/*.png`
do
convert $img -strip $img.gif
done

cheers

Re: change names using convert on multiple files

Posted: 2007-07-10T04:31:15-07:00
by sparkly
found a solution that is working, added this to my script:

for f in thumbs/*.png.gif; do
base=`basename $f .png.gif`
mv -v $f thumbs/$base.gif
done

cheers,
M

Re: change names using convert on multiple files

Posted: 2007-07-11T00:42:00-07:00
by anthony
You can also use mogrify which replaces the suffix using -format
and the path using -path.... See Im exmaples
http://www.imagemagick.org/Usage/basics/#mogrify