开发者

How to output date to a text file, filename in Windows XP

I have tried many ways of doing this in a batch file, although when outputting to a filename, I get "/" in them, so it can't output it to a text file, I realize they differ, so one which works in XP and Vista / 7 would be handy

E.g. Set FileDate=%date:/=%
开发者_运维技巧


Try this:

I had written it a while ago.

@echo off
setlocal ENABLEDELAYEDEXPANSION

set today=!date:/=-!
set now=!time::=-!
set millis=!now:*.=!
set now=!now:.%millis%=!

echo hello world > my-file-!today!_!now!.txt
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜