I know I’m going to forget how I did this again, especially if I lose the following script I wrote, so I’m posting it here. Here’s the gist: a directory full of files and I want to to copy them to a new location while also changing them to lower-case, using a different extension (MOD => mpg), and finally including the Last Modified date in the name (YYMMDD-hhmmss).
#! /bin/bash for file in $1/*.MOD do modifdate=`stat -c %y $file` formatdate=`date -d "$modifdate" "+%Y%m%d-%0k%M%S"` echo "cp -p -u $file $2/mov-$formatdate.mpg" cp -p -u $file $2/mov-$formatdate.mpg done
Note to myself: you called it movcp and put it in /usr/bin. Thus I go from this …
Using this …
To this:
Voila! Now I can archive these off to my ReadyNAS and online backup.


