Use 7z+*.BAT to backup at work

Following the previous post, I apply the application, 7z (http://www.7-zip.org/), instead this time. The reason is obvious: sometimes our work environment might not allow us installing WinRar.
The major differences are

  1. 7zip doesn't support auto-seed in parameter (in another word, 7zip will replace the file with the same file name because of using "a" in parameter). Therefore, I have to get the "seeds" from current time.
  2. 7zip will show the detail during the compressing process (i.e. print out every file name). Thus I use the command script to output the detail into a TXT file, log.txt.
Script as BAT:

@echo off
SETLOCAL
@ECHO Begin to backup
for /F "tokens=1-3 delims=/ " %%i in ('date /t') do (
set strPre=%%i%%j%%k
)
for /f "tokens=1-3 delims=:." %%i IN ("%time%") DO (
set strseed=%%i%%j%%k
)
"C:\Program Files\7-Zip\7z.exe" a -t7z -mx=7 -ssw <target path>\%strPre%_%strseed% <source path>\* >> log.txt
@ECHO End backup
ENDLOCAL

留言

這個網誌中的熱門文章

Excel技巧(1):檔案肥大的原因,附上減肥撇步

Excel技巧(2):拜託殺了那些看不見的空白吧!