A Better Way to Convert ppm to jpeg in Linux

So two months ago I posted the scripts I used to convert ppm to jpegs in my Ubuntu setup. I knew it was poorly done because it renamed every file picture.ppm.jpeg, and it needed two seperate files to work. Thanks to commenter Manuel, I finally have a much better way to do it.

for pic in *.ppm
pnmtojpeg "${pic}" > "${pic/%ppm/jpg}"

Then just put that in your path somewhere, chmod +x ppmconv, and you're good to go.

To add it to your path, add this line to your ~/.bashrc file:
Then add whatever scripts you want into ~/bin to have them run. Right now the only other thing I have in there is my twitter script.

My dad and I were actually talking about this exact same solution to my problem on the way up to Davis last week, so I at least knew it was bad (Not to mention unstable...). Thank Manuel!

Popular Posts