Reputation: 131
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.
Upvotes: 13
Views: 16522
Reputation: 15
forfiles /M . /S /C "cmd /c echo @path @fdate @ftime" >> dir_path_date.txt
Upvotes: 0
Reputation: 71
@echo off
REM list files with timestamp
REM Filename first then timestamp
for /R %%I in (*.*) do @echo %%~dpnxI %%~tI
@echo off
REM list files with timestamp
REM Timestamp first then name
for /R %%I in (*.*) do @echo %%~tI %%~dpnxI
Upvotes: 0
Reputation: 121
You can also use use dbenham answer for /f "eol=: delims=" %F in ('dir /b /s') do @echo ... to dump information like:
i.e. using the lines below You can make csv dump of directory with subdirectories and file details
for /f "eol=: delims=" %F in ('dir /b /s') do @echo %F;%~zF;%~dF;%~pF;%~nF;%~xF;%~tF;
results:
full_path;size;drive;path;name;extension;date
E:\dump\oc.txt;37686;E:;\dump\;oc;.txt;2020-04-05 20:10;
Upvotes: 3
Reputation: 1
How about something like this:
for /f "tokens=*" %a in ('dir *.* /a:d /b /s') do for /f "skip=5 tokens=1,2,3,4*" %b in ('dir *.* /a:-d') do @if %e neq bytes @echo %a\%e%f %b %c
Simples, although I may have complicated it a little :-)
Upvotes: 0
Reputation: 130819
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
.
Upvotes: 18
Reputation: 4923
There is no direct way of doing this using DIR. You would need to write a wrapper that stripped the extraneous details from a DIR /s
You could use either powershell, vbscript or javascript to do this.
Here is a related answer using PowerShell: How to retrieve a recursive directory and file list from PowerShell excluding some files and folders? though you would need to amend this to add the date/time.
UPDATE: Here is a MAD site that lists a recursive directory walk in loads of different languages: http://rosettacode.org/wiki/Walk_a_directory/Recursively
Upvotes: 1