开发者

Windows batch: date format variable not printing correctly

So i have this code.

FOR /F "tokens=*" %%A IN ('dateFormat +"%Y/%m/%d %T"') DO SET Now=%%A
CALL run_some_job "%Now%"

my output.

JOB_FILE_PATH>FOR /F "tokens=*" %A IN ('dateFormat +"m/T"
') DO SET Now=%A

JOB_FILE_PATH>开发者_Go百科;SET Now=m/T

JOB_FILE_PATH>CALL run_some_job  m/T

I use the dateFormat tool from date.exe in this. http://unxutils.sourceforge.net/ to print date. If i do dateFormat +"%Y/%m/%d %T", than it works correctly.

Thanks


You need to escape the percent signs in the date format argument:

FOR /F "tokens=*" %%A IN ('c:\utils\date +"%%Y/%%m/%%d %%T"') DO SET Now=%%A
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜