Etope-O-Mat.sh

#!/bin/bash

# get image name
if [ -z $1 ]; then
# read from dialog
INPUT=$(zenity --title "Etope-O-Mat" --entry --text "Bildname:")
else
# copy input from command line
INPUT=$@
fi

for IMAGE in $INPUT; do
# convert image name to lower case
IMAGE=$(echo ${IMAGE} | tr "[:upper:]" "[:lower:]")

# add .jpg file extension if not already exists
IMAGE="${IMAGE/.jpg}.jpg"

# set input and output
PATH_IN=/media/bilder/300dpi
PATH_OUT=/home/$USER/200px
FILE_IN="${PATH_IN}/${IMAGE}"
FILE_OUT="${PATH_OUT}/${IMAGE}"

# check dirs
[ ! -d $PATH_OUT ] && mkdir $PATH_OUT

# convert image
if [ -f $FILE_IN ]; then
convert $FILE_IN -resize "200x200>" -size 200x200 xc:white +swap -gravity center -composite $FILE_OUT
else
zenity --info --title "Datei nicht gefunden" --text "Die Datei $IMAGE konnte nicht gefunden werden"
fi
done | zenity --auto-close --progress --title="Etope-O-Mat" --text="Bearbeite $IMAGE..."