#!/bin/bash if [ "$1" == "" ] ; then echo Use the timestamped name of Canon .thm files to timestamp corresponding .avi files echo Specify the directory at the root of the tree to operate on: echo " " `basename $0` dir exit fi if [ -d "$1" ] ; then # if we've got a directory then do a find on it and call ourself with each .avi file found echo $1 find $1 -name '*.avi' -exec $0 {} \; exit fi if [ ! -f "$1" ] ; then echo "*** ERROR *** must have name of file to convert or directory to start"; exit; fi # if we've got a file then we've been called by find (above) to timestamp it from its .thm # strip the directory path from the file+ext filext=`basename "$1"` # get the directory part of the filespec by losing everything after the last '/' path=`echo $1 | sed -e 's/[^\/]*$//'` # get the filename without the '.avi' extension file=`basename "$filext" .avi` # try to find the .thm file corresponding to this .avi thmfile=`ls "${path}" | grep "$file.thm"` if [ "$thmfile" != "" ] ; then # get the timestamped name of the .thm file without its extension thmbase=`basename $thmfile .thm` # rename the .avi file with this timestamped name echo mv "$1" '->' "${path}${thmbase}.avi" mv "$1" "${path}${thmbase}.avi" fi