#!/bin/zsh PICDIR=$HOME/pictures DATADIR=$1 if [ -z "$DATADIR" ] ; then echo -n "Please tell me where to find the pictures: " ; read DATADIR fi ### zsh has the **/ globbing feature that acts similar to ### for i in `find $DATADIR -name "*.jpg"` ### except for the facts that ### - it does not spawn another process ### - it handles whitespace in filenames without any hassle for i in $DATADIR/**/*.jpg ; do D=$(exiftags $i 2>/dev/null | grep "^Image Created" | sed -e 's/Image Created: //' -e 's/:/-/g' -e 's/ .*//') # echo $D mkdir -p $PICDIR/$D/auto cp -v $i $PICDIR/$D/auto done