![Windows 批处理文件 7 使用日期范围压缩存档文件](https://linux22.com/image/1320442/Windows%20%E6%89%B9%E5%A4%84%E7%90%86%E6%96%87%E4%BB%B6%207%20%E4%BD%BF%E7%94%A8%E6%97%A5%E6%9C%9F%E8%8C%83%E5%9B%B4%E5%8E%8B%E7%BC%A9%E5%AD%98%E6%A1%A3%E6%96%87%E4%BB%B6.png)
我目前正在运行一个批处理文件,该文件使用旧版本的 Winzip 备份过去 24 小时内创建或修改的所有文件。我使用 7 zip 进行大量存档,并希望能够将其用于此目的,但它没有允许您根据日期/时间戳选择文件的开关。我不想根据文件的时间戳将文件复制到目录并从那里存档。有什么建议吗?
答案1
http://ss64.com/nt/forfiles.html
和
http://www.dotnetperls.com/7-zip-examples ->
forfiles /c "7za a -t7z @fname.7z @file" /d -1
答案2
经过一些研究,我想到了一些可行的方法......
forfiles /c "cmd /c 7z u -t7z [setup an empty 7z file].7z @path" /d -1 /s
答案3
关闭但将使用这些开关存档超过一天的文件,这是当前日期的语法(在输出文件中添加了日期:
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
Rem - compress data that is from current day
forfiles /p "c:\<path of what to backup>" /d 0 /c "cmd /c C:\<Location of 7zip>\7za u -tzip D:\<Where you want archive saved>\Archive_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%.zip @PATH -mmt"