cmd dir /b/s plus date

user1483922 picture user1483922 · Jun 26, 2012 · Viewed 13.5k times · Source

I am looking for a cmd shell command in Windows XP, like "dir /b/s" that includes date and time values for each file in result. All data - path, filename and date/time - need to be on one line. Can anyone provide a command to accomplish this? Thank you.

Answer

dbenham picture dbenham · Jun 27, 2012

If you want files only

for /r %F in (*) do @echo %~tF %F

If you want both files and directories then use the DIR command with FOR /F

for /f "eol=: delims=" %F in ('dir /b /s') do @echo %~tF %F

If used in a batch file then %F and %~tF must change to %%F and %%~tF.