This means copying them and renaming, i.e. warysaveA.3fs becomes warysave-11-09-22_10.13.3fs.
Once I got started writing a script however I realized that it might be handy for this to work on any file or folder so I set it up that way.
I have placed "mk_dated_backup" on the rox right click "Open With" menu.
Just right click on any file or folder, go to "Open With" and choose "mk_dated_backup". The backup will be created in the same folder as the original and a gxmessage will appear when it is finished.
I have attached dated_backup.pet-0.2
Enjoy, J
Notes:
- Anything after the last dot (.) in a filename will be treated as an extension and placed after the date and time in the new filename.
- .pets will not work if you change their file name
Changelog
_____________________________
Version 0.2 (25 Sep 2011)
- Everything after the word "save" in a file name will be replaced with the time and date and the original extension.
- mk_dated_backup has been placed on the rox right click menu for .2fs, .3fs, .4fs, scripts and plain text. For all other files it is still on the OpenWith menu
Here's the new code:
Code: Select all
#!/bin/sh
#Make a dated backup of any file or folder with same extension - jrb 22sep11
#Removal of previous dates on pupsave file - jrb 25sep11
#Notes - .pets will not work if you change their file name
#Anything after the last dot (.) in a filename will be treated as an extension
#and placed after the date and time in the new filename.
FILE=$@
FNAME=`basename $FILE`
FRST=${FNAME%%save*}
LAST=${FNAME##*save}
DIR=`dirname $FILE`
EXT1=${FILE##*.}
#if file has no extension must use the following:
if [ $FILE = $EXT1 ]
then
EXT2=""
else
EXT2=.$EXT1
fi
#Everything after the word "save" in a file name will be
#replaced with the time and date and the original extension.
#This includes any descriptors you may have placed on your save file.
if [ $FRST = $LAST ]
then
OLDFILE=`basename $FILE .$EXT1`
else
OLDFILE="$FRST"save
fi
NEWFILE="$OLDFILE"-`date +%y-%m-%d_%H.%M`$EXT2
cd $DIR
cp -r $FILE $DIR/$NEWFILE
gxmessage -center -bg orange "Backup finished"