How to get file's last modified date on Windows command line?

前端 未结 8 1642
星月不相逢
星月不相逢 2020-12-01 04:16

I have been using the following command to get the file date. However, the fileDate variable has been returning blank value ever since we moved to a different s

8条回答
  •  感动是毒
    2020-12-01 04:32

    What output (exactly) does dir myfile.txt give in the current directory? What happens if you set the delimiters?

    FOR /f "tokens=1,2* delims= " %%a in ('dir myfile.txt^|find /i " myfile.txt"') DO SET fileDate=%%a 
    

    (note the space after delims=)
    (to make life easier, you can do this from the command line by replacing %%a with %a)

提交回复
热议问题