Thursday, February 4, 2010

Renumbering files in consecutive order

Here is a small script I used to renumber files in consecutive order. Of course you need to change it to suite your needs.
files=`find . -name "images*.pgm"`
i=0
for f in $files;
do
i=`expr $i + 1`
newf=`printf "test/images%03d.pgm" $i`
mv $f $newf;
done

Sunday, August 30, 2009

How to batch extract frames from video

I also needed to extract frames from a video , for that I used ffmpeg
ffmpeg -i movie1.MPG -r 1 -f image2 frames/images%d.png

Batch converting images

Today I had to batch convert images from png to pgm. Here how you can do it using Imagemagick
mogrify -format pgm *.png