#!/bin/bash # # batchconvert # script by david buchmann, budda@budda.ch # thanks to robert regn for input on sed # # call convert repeatedly to convert lots of files at a time # version: 0.1, 16.2.2003 # changelog: # # 26.4.2007: Thanks to an input from Robert Regn, the script now handles # filenames with points corretly (using stream editor sed) # If you do not have sed, you can uncomment the old code. # 21.1.2004: Using IFS=. and set, we split filenames - but if you have # filenames containing points, you loose the parts after first point # 16.2.2003: Intial Version, generating double extensions # #this program is provided as is. no warranty at all. # if [ $1=t ] ; then shift; if [ "$1" != "" ] ; then exten=$1 ; shift for i in $* ; do #old code for filename without sed # IFS=. # set -- $i # name=$1 # IFS=" " # if [ $# != 2 ] ; then # echo "Warning: This script is not able to handle filenames with more than one point. It will break the filename of" $i # fi name=`echo $i | sed 's-.[^.]*$--'` #new code with sed. comment out if you need the old code. convert $i $name.$exten done #exit with success exit 0 fi fi echo "Usage: batchconvert t files" echo "Example: batchconvert t png *.tga" exit 1