Simple BASH shell script to rename webcam jpg and copy into a new directory.

System: Ubuntu Intrepid Ibex

I'm running webcamd as a sort of "security" program, but I need a script that will archive my webcam.jpg files.

So, take the following file:
/home/slag/www/webcam.jpg

Rename it--preferably with a time stamp.

Place it in say:
/home/slag/www/history/

Copying the file say ever 60 seconds or so.

And that's it. I wont need to run this as a cronjob as I'll just execute the script from a screen when needed.

Thanks guys!

Rob Findlay

while :
do
    orig=/home/slag/www/webcam.jpg
    dest=/home/slag/www/history
    destfile=${orig%.jpg}$( date +%Y-%m-%d_%H.%M.%S ).jpg
    mv "$orig" "$dest/$destfile"
    sleep 60
done

Thanks again for the help!

This is what I get when i execute:

mv: cannot move `/home/slag/www/webcam.jpg' to `/home/slag/www/history//home/slag/www/webcam2009-03-21_22.43.57.jpg': No such file or directorhe script:

It's doubling the directory somewhere, though I'm so new to bash i don't see where the error is :frowning:

-R

My mistake; it should be:

while :
do
    orig=/home/slag/www/webcam.jpg
    dest=/home/slag/www/history
    origfile=${orig##*/}   ## this step was missing
    destfile=${origfile%.jpg}$( date +%Y-%m-%d_%H.%M.%S ).jpg
    echo mv "$orig" "$dest/$destfile"
    sleep 60
done

thank you!!!!