开发者

Batch For /F Syntax with %time%

开发者 https://www.devze.com 2023-01-04 04:38 出处:网络
How do I accomplish this: for /f \"tokens=1-4 delims=: \" %%a in (\'%time%\') do set XTime=%%a.%%b.%%c.%%d

How do I accomplish this:

for /f "tokens=1-4 delims=: " %%a in ('%time%') do set XTime=%%a.%%b.%%c.%%d

I'm trying to get the contents of %time% e.g.开发者_运维百科, 16:25:15.65 into 16.25.15.65.

Running the command above gives me:

The filename, directory name, or volume label syntax is incorrect.

(If it matters I'm on Windows XP)


Figured it out, turns out I just needed double quotes:

for /f "tokens=1-4 delims=: " %%a in ("%time%") do set XTime=%%a.%%b.%%c.%%d
0

精彩评论

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