使用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:\RACHAEL\my_work\dbs\MyDb\%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:\RACHAEL\my_work\dbs\MyDb\%DATE:~11,4%\%DATE:~5,2%\MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak.zip -i!C:\RACHAEL\my_work\dbs\MyDb_bak_<get_current_date_in_correct_format>.bak
如何从批处理文件中找到包含当前格式化日期的文件在此目录中?有逃脱符吗?
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:\RACHAEL\my_work\dbs\MyDb\%DATE:~11,4%\%DATE:~5,2%\MyDb_bak_%DATE:~11,4%-%DATE:~5,2%-%DATE:~8,2%.bak.zip -i!^C:\RACHAEL\my_work\dbs\MyDb\%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屋!