Since you did post your script, I thought I'd give you some comments on that script, because you are doing a few odd things there.
1.
Code:
which convert > /dev/null
if [ $? -eq 1 ]; then
echo "Geen Imagemagick gevonden!"
exit 1
fi
«which» is an external command, and bash can do that check itself with the built-ins «command» and «type». Also, checking the value of $? is pointless when you only need to know if it's true or false.
Code:
if ! command -v convert >/dev/null; then
echo "no imagemagick..."
exit 1
fi
http://mywiki.wooledge.org/BashFAQ/081
2.
Code:
while [ $# -gt 0 ]; do
picture=$1
«...snipp...»
shift
done
Just iterate "$@" with a for-loop «for picture in "$@"; do...», though actually, you can omit the «in "$@"» part because that's the default. (see «help for»)
Code:
for picture; do
...
done
3.
Code:
resized_file=`echo $picture | sed 's/\.\w*$/-resized.jpg/'`
reduced_quality_file=`echo $picture | sed 's/\.\w*$/smaller.jpg/'`
Another thing bash can do without the use of external commands
Code:
resized_file=${picture%.*}-resized.jpg
reduced_quality_file=${picture%.*}smaller.jpg
http://mywiki.wooledge.org/BashFAQ/073
4.
Code:
convert -resize $SIZE $picture $resized_file
In your initial script you had $picture and $resized_file properly quoted. Why did you remove them? Without those quotes, it will break on filenames with whitespace and other special characters.
5.
Code:
QUALITY=`(zenity --scale --text "Is $jpg_size klein genoeg? Zoniet: pas de kwaliteit aan:" --min-value=2 --max-value=100 --value=40 --step 2)`
Those parenthesis are generating another subshell in the subshell created by ``. That's pointless overhead.
Also, in general it's better to use $() rather than ``.
http://mywiki.wooledge.org/CommandSubstitution
Bookmarks