#!/bin/sh # # Copies JPEG files in the current directory photos to smaller pictures # (15% of the original size by default) in the sm subdirectory. # # Author: R.F. Smith # Time-stamp: <2010-08-29 14:54:28 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to mksmall. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ # Check for special programs that are used in this script. PROGS="convert" for P in $PROGS; do which $P >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "$(basename $0): The program \"$P\" cannot be found." exit 1 fi done FILES=`ls *.jpg|sed -e 's/\.jpg//g'` SZ=15 if [ $# -gt 0 ]; then SZ=$1 echo "Scaling to ${SZ}%." fi if [ -z '$FILES' ]; then echo "No JPEG files found" exit 1; fi # Remove old small files rm -rf sm mkdir sm # Make small files for n in $FILES; do echo "Converting ${n}.jpg to sm/${n}_sm.jpg." convert -scale $SZ% ${n}.jpg sm/${n}_sm.jpg done