项目向前移动,我可以看到为什么创建.bat文件来做事情会让人上瘾!我现在可以定期保存somefile.txt,然后通过添加时间和日期重命名somefile.txt来创建一个唯一的文件名
ren somefile.txt somefile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~3,2%%date:~-4,4%.txt
Run Code Online (Sandbox Code Playgroud)
例如,上面的代码刚刚重命名somefile.txt为somefile_1317_13022011.txt (1317hrs on 13th February 2011)
我跑了
ren somefile.txt somefile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~7,2%%date:~-4,4%.txt
Run Code Online (Sandbox Code Playgroud)
昨天,它成功运行到午夜,然后崩溃(语法错误)虽然它保存为日期(2011年1月12日)的12012011而不是正确的日期12022011.
当前版本是否会在午夜过后?我对英国与美国的日期格式混淆了吗?