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.
The command DIR /b will return just a list of filenames, when displaying subfolders with DIR /b /s the command will return a full pathname. To list the full path without including subfolders, use the WHERE command.
The dir command displays a list of files and subdirectories in a directory. With the /S option, it recurses subdirectories and lists their contents as well.
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
.
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;
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With