Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep multiple versions(999+) of your source files ?

Utility Program

How to keep multiple versions(999+) of your source files ?

by  NasibKalsi  Posted    (Edited  )
For Backup/Zip download any of the tools such as cabarc(MicroSoft), Zip tools, etc. Replace the pkzip line in the code with your own file generating utility/program. You may comment out that line if file generation is not required. To see the demo, create a directory on c:\Bak123. Then create 2 dummy files abcd.101, abcd.102 respectively. Comment the pkzip line. Save the code into c:\Bak123\bak123.bat and run in dos windows.



Code:
@echo off
rem -----------------------------------------------------
rem This batch file will rename files of the order
rem abcd.102 to abcd.103
rem abcd.101 to abcd.102
rem and frees the first slot for a newer file.
rem This utility batch can be used for keeping last upto 899 files,
rem for backup(old versions). It may be helpful in case the class, or other files
rem get corrupted and requires a backup. 
rem Uses pkzip.exe. You can use any other zip/report program which generate a single file
rem that requires last finite number of versions(999,9999, ...)
rem
rem No (c) copyright of any kind.
rem Nasib Kalsi 2007-12-02
rem 
rem Handle files of the order abcd.199, abcd.198,  ... abcd.101
rem
echo .
echo . Working, please wait
echo .

rem --------------------------------------------------
rem Modify the following parameters as per your requirements
rem No spaces around = sign
set SourceFiles=p:\uw\inv\*.*
set BakDir=c:\Bak123
set FileName=abcd

set/a RootFileExt  = 100
set/a FirstFileExt = RootFileExt + 1
set/a LastFileExt  = 199

rem --------------------------------------------------

rem Make BackupDir
if exist %BakDir%\%FileName%.%FirstFileExt% goto Begin
md %BakDir%

:Begin
   set /a LastFileExt = LastFileExt - 1
   if %LastFileExt%==%RootFileExt% goto End
   if exist %BakDir%\%FileName%.%LastFileExt% goto Yes
   goto Begin

:Yes
   set /a j = LastFileExt + 1
   ren %BakDir%\%FileName%.%LastFileExt% %FileName%.%j%
   goto Begin

:End


:ZipNow
rem Now create a zip/report file in slot 101 (abcd.101)
pkzip %BakDir%\%FileName%.%FirstFileExt% %SourceFiles%

echo .
echo . Done
echo .
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top