使用 7zip 仅包含 *当前日期* 的文件 [英] Use 7zip to include files with *current date* only
问题描述
我正在创建一个文件,然后用 7-zip 压缩一个标有当前日期的文件.我可以使用以下开关来创建要添加到的 zip 文件:
I'm creating then zipping a file that is stamped with the current date with 7-zip. I am able to use the following switch to create the zip file to add to:
7z -tzi C:RACHAELmy_workdbsMyDb\%DATE:~11,4%\%DATE:~5,2%MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak.zip
但添加-i!"命令找不到指定的文件
but adding the "-i!" command does not locate the file specfied
7z -tzi C:RACHAELmy_workdbsMyDb\%DATE:~11,4%\%DATE:~5,2%MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak.zip -i!C:RACHAELmy_workdbsMyDb_bak_<get_current_date_in_correct_format>.bak
如何从批处理文件中找到包含当前格式化日期的目录中的文件?有转义符吗?'%' 在 7zip 中没有提供这个目的,我认为它会.
How would one achieve locating the file in this directory containing the current formatted date from a batch file? Is there an escape character? The '%' does not provide this purpose in 7zip, which I assumed it would.
提前致谢!
推荐答案
在我尝试添加到使用 7zip 创建的成功压缩目录的路径之前缺少转义字符 ^
.
was missing the escape character ^
before the path I was trying to add to the successfully zipped directory created with 7zip.
这是更正的声明:
echo Using 7-zip to compress today's backup folder...
7z a -tzip C:RACHAELmy_workdbsMyDb\%DATE:~11,4%\%DATE:~5,2%MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak.zip -i!^C:RACHAELmy_workdbsMyDb\%DATE:~11,4%\%DATE:~5,2%MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak
^missing escape character right here so that path could actually be parsed per date format.
这篇关于使用 7zip 仅包含 *当前日期* 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!