Wednesday 6 June 2007

Using the shell

Never underestimate the power of the UNIX shell! The following one-liner converts a batch of files from gif to jpeg for you

for file in *.gif; do convert ${file} ${file%gif}png; done

Note that the %gif removes gif from the file name for you. If you are trying to create such a one-liner it is very convenient to use echo to first print commands before actually executing them, so

for file in *.gif; do echo convert ${file} ${file%gif}png; done

is harmless but gives you an indication of what will happen.

No comments: