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

前端 未结 8 1549
星月不相逢
星月不相逢 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:41

    It works for me on Vista. Some things to try:

    1. Replace find with the fully-qualified path of the find command. find is a common tool name. There's a unix find that is very differet from the Windows built-in find. like this:
      FOR /f %%a in ('dir ^|%windir%\system32\find.exe /i "myfile.txt"') DO SET fileDate=%%a

    2. examine the output of the command in a cmd.exe window. To do that, You need to replace the %% with %.
      FOR /f %a in ('dir ^|c:\windows\system32\find.exe /i "myfile.txt"') DO SET fileDate=%a
      That may give you some ideas.

    3. If that shows up as blank, then again, at a command prompt, try this:

      dir | c:\windows\system32\find.exe /i "myfile.txt"

    This should show you what you need to see.

    If you still can't figure it out from that, edit your post to include what you see from these commands and someone will help you.

    0 讨论(0)
  • 2020-12-01 04:45

    You can do it

    forfiles /M myfile.txt /C "cmd /c echo @fdate @ftime"
    
    0 讨论(0)
提交回复
热议问题