如何追加在批处理文件中的日期 [英] How to append a date in batch files

查看:124
本文介绍了如何追加在批处理文件中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件以下行(运行在一个旧的Windows 2000 箱):

I have the following line in a batch file (that runs on an old Windows 2000 box):

7z a QuickBackup.zip *.backup

我如何追加日期到 QuickBackup.zip 文件。所以,如果我今天跑的批处理文件,理想情况下,该文件将是 QuickBackup20090514.zip

How do I append the date to the QuickBackup.zip file. So if I ran the batch file today, ideally, the file would be QuickBackup20090514.zip.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

伯恩哈德的回答需要一些调整工作,为我,因为在%DATE%环境变量是在不同的格式(如其他地方注释)。此外,还有缺少符号(〜)。

Bernhard's answer needed some tweaking work for me because the %DATE% environment variable is in a different format (as commented elsewhere). Also, there was a tilde (~) missing.

而不是:

设置backupFilename =%DATE:〜6.4 %%日期:3,2〜%%日期:0,2%

我不得不使用

设置backupFilename =%DATE:10,4〜%%日期:4,2〜%%日期:7,2〜%

有关的日期格式为:

C:\\脚本>回声%DATE%

c:\Scripts>echo %DATE%

周四2009年5月14日

Thu 05/14/2009

这篇关于如何追加在批处理文件中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆