Robocopy批处理文件移动和zip文件夹和输出日志

时间:2014-02-14 01:15:28

标签: batch-file backup 7zip robocopy logfile

这就是我目前所拥有的:

ROBOCOPY C:\A\move\Logs C:\A\move\moved /MOVE /S /MINAGE:5 /log+:output.log
for /d %%X in (*) do (
"c:\Program Files\7-Zip\7z.exe" a "LOG"%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4%Backup.zip" "%%X\" 
pause

我在尝试设置批处理以使用7zip将Destination文件夹压缩为zip文件时遇到了一些麻烦。有什么建议或帮助吗?

1 个答案:

答案 0 :(得分:1)

我会从这开始:

@ECHO off
SET "7ZIP=c:\Program Files\7-Zip\7za.exe"
SET "FROM=C:\A\move\Logs"
SET "TO=C:\A\move\moved"
SET OUTPUT=output.log
SET DD=%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4%

if not exist %7ZIP% ECHO No 7z && GOTO :END

ROBOCOPY %FROM% %TO% /MOVE /S /MINAGE:5 /log+:%OUTPUT%

for /d %%X in (*) do (
  "%7ZIP%" a -tzip "LOG_%DD%_%%X_Backup.zip" %%X
)

:END
pause