Send a link

retouch

Shell script to touch dirs again

#!/bin/sh

touchone () {
        echo "Touching directory $1"
        NFO=`ls -1 $1*.nfo|tail -1`
        SFV=`ls -1 $1*.sfv|tail -1`
        if [ -e "$NFO" ]; then
                touch -r $NFO $1.
        else
                if [ -e "$SFV" ]; then
                        touch -r $SFV $1.
                else
                       echo "No NFO or SFV file found - consider using: $0 -1"
                fi
        fi
}

case "$1" in
-1)
        touchone
        ;;
*)
        for x in `ls -1`; do
                if [ -d "$x" ]; then
                        touchone $x/
                else
                        echo "NOT A DIRECTORY: $x - consider using: $0 -1"
                        exit 1
                fi
        done
        ;;
esac