#!/bin/bash echo "`basename $0`, Spawn 2007" DIRECTORY="./" EXT="JPG" EXT2="jpg" converted="new_photo" VALUE=60 procedure () { for file in *.$EXT *.$EXT2 do `convert -resize $VALUE% $file $DIRECTORY/$file` done exit 0 } case $1 in "-h") echo "usage: `basename $0` [-d ]" echo "usage for convert only one photo: `basename $0` [-s ]" echo "-d is the directory that you want to put your output, if not specified will be used the current directory." echo "WARNING: If the output directory it is the same of the input, all your foto will be replaced!!" echo echo "-s option for resize only one photo" echo "example: spawn_convert_photo -s 70 pict.jpg new -> this option will resize your pict by 30%" echo echo "-h show this output and exit" exit 0 ;; "-d") DIRECTORY=$2 procedure ;; "-s") case $2 in *) VALUE=$2 ;; esac case $3 in *) photo=$3 ;; esac case $4 in *) converted=$4 ;; esac `convert -resize $VALUE% $photo $converted.$EXT2` exit 0 ;; esac if [ "./" = $DIRECTORY ] then echo "This option will be replace all your original photo with the new converted photo, are you sure? use -d option for put the new photo in another directory! you have 10 second to stop the process!" for ((a=1; a <= 10; a++)) do sleep 1 echo " $a second...." done fi procedure