Skip to content

converting multiple files

converting multiple PNG files to PNG files with a width of 400 pixels

for i in !(*-small.png) ; do if test ! -s "${i%.*}-small.png" ; then convert "$i" -resize '400' "${i%.*}-small.png" ; fi ; done

converting multiple TIFF files to PNG files

In the current directory, each file with the .tiff file extension not already accompanied by a file with .png in place of .tiff or -intermediate.png in place of .tiff will be converted into two PNG files.

for i in *.tiff ; do if { test ! -s "${i%.*}-intermediate.png" && test ! -s "${i%.*}.png"; } ; then convert "$i" "${i%.*}-intermediate.png" && pngcrush "${i%.*}-intermediate.png" "${i%.*}.png" ; fi ; done



This is an incomplete explanation.

prior work


Some rights reserved: CC BY-SA 3.0. Includes significant content from an answer on Super User by Kevin Cox and test (Unix)§Examples on Wikipedia, with changes made.