cmd: save wmic output to variable
问题 I am trying to get the timestamp of a file into a variable in a batch file. My batch file, imagetime.bat contains the following: set targetfile=%~1 set targetfile=%targetfile:\=\\% echo %targetfile% for /f "usebackq delims=" %%i in ( `wmic datafile where name^="%targetfile%" get creationdate` ) do ( echo %%i ) echo %timestamp% And I get this output: C:\>imagetime.bat V:\setup.exe C:\>set targetfile=V:\setup.exe C:\>set targetfile=V:\\setup.exe C:\>echo V:\\setup.exe V:\\setup.exe C:\>for /F