File: XTree:\Forum-Archive |Bottom_of_page

| View Thread | Return to Index | Read Prev Msg | Read Next Msg |

XTree Forum-Archive

Backup on Alt Edit

Posted By: Gavin <>
Date: Jan-7-2005 6:01 p.m.

If you send a lot of time editing/running script files and want a quick way to keep backups (Source code control) then consider the following batch file

rem---Bat file starts
@echo off
rem Developed under windows XP SP2
rem This needs the cmd shell "short date format" to be yyyy/MM/dd -
rem change via "control panel" "regional settings"
rem Make a directory tree from yyy/MM/hh/mm/ss
FOR /F "delims=:. tokens=1,2,3 " %%i IN ("%time%") DO MD "%Date%\%%i\%%j\%%k"
rem delims=:. is required to separate hours/mins/secs/10th100ths
rem n.b. loose the 10ths100ths (token 4)
rem Copy the file %1 to the correct location
FOR /F "delims=:. tokens=1,2,3 " %%i IN ("%time%") DO copy %1 "%Date%\%%i\%%j\%%k\%1"
rem Add to the archive
FOR /F "delims=:. tokens=1,2,3 " %%i IN ("%time%") DO \programs\ztree\addins\7za.exe a -tzip "%Date%\%%i\%%j\%%k\%1"
rem Remove the copy and the directory tree
del /s/q "%Date%\*.*"
rd /s/q "%Date%\..\.."
rem Call up editor for file
start \programs\ztree\addins\metapad.exe %1
rem---Bat file ends

It uses a freeware zip tool (7za.exe) to store copies of your files each time you edit them. I choose to have one backup archive per directory - but you could change this. Any similar tool supporting subdirectories will do.

To keep the files from overwriting I have a directory tree in the zip file created from the date-time (yyyy/MM/hh/mm/ss) that the file was ADDED to the archive. This creates unique backups assuming you can't edit the file and re-save in less than 1 second!.

To see what is happening comment out the section with a "REM ". Hopefully you will see a directory structure built up from 2005\ onwards - if not go change the system short date format.

I use this from ztree and can retrieve any save version using the Alt-F5 zip browser. Sort by branch is very useful to get the versions all in order.

Kind Regards

Messages in This Thread

| View Thread | Return to Index | Read Prev Msg | Read Next Msg |

XTree Forum-Archive is maintained by Mathias Winkler with WebBBS 3.21.

Xtree and XtreeGold are registered trademarks of Symantec Inc.
Other brands and products are trademarks of their respective holders.

FILE COMMANDS:  Directory_view Previous_file   Next_file aRchive   /Help |Top_of_page