Friday, November 11, 2005

Still using DOS

Here's one of my DOS batch scripts that I still use to backup my source code

Can't imagine after all these years I'm still using DOS batch file and DOS Rar to help me with my daily backup.

useful because it compresses all the files in a folder using RAR and names the compressed file according to the date (yyyy-mm-dd).

@echo off
echo Backing Up RHB Fin files
echo =============================
rar a -m5 -r c:\backup\rhbbackup%year%-%month%-%day% c:\www\rhbproj1

:GetDate yy mm dd
:: By: Ritchie Lawrence, 2002-06-15. Version 1.0
:: Func: Loads local system date components into args 1 to 3. For NT4/2K/XP
:: Args: %1 var to receive year, 4 digits (by ref)
:: %2 var to receive month, 2 digits, 01 to 12 (by ref)
:: %3 Var to receive day of month, 2 digits, 01 to 31 (by ref)
set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
set %%a=%%d&set %%b=%%e&set %%c=%%f))
endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF

1 comment:

黄德峻 said...

dos still powerful