How to format dir command in cmd for XP and Win 2000

298 views Asked by At

When I use dir command in win XP it returns all kind of info:

Volume in drive C is OSDisk
Volume Serial Number is AEF7-B35F

Directory of C:\Users\bd250124\Desktop\test

06/11/2015  12:14 PM    <DIR>          .
06/11/2015  12:14 PM    <DIR>          ..
06/11/2015  12:14 PM                10 test01.txt
06/11/2015  12:13 PM                 0 test02.txt
               2 File(s)             10 bytes
               2 Dir(s)  261,280,952,320 bytes free

The problem is that I don't need all that info, I need only file name and last write time. Is there any way to format it, google is not returning any results, and to repeat I'm on win XP and 2000.

2

There are 2 answers

1
JosefZ On BEST ANSWER

Command line:

for /F "delims=" %G in ('dir /B /A:-D') do @echo %~tG %G

Batch (note %%G instead of %G):

for /F "delims=" %%G in ('dir /B /A:-D') do @echo %%~tG %%G

Resources (required reading):

0
MC ND On
for %a in ("c:\somewhere\*" "d:\here\*.txt" "\\server\share\path\*.doc") do @echo %~ta %~fa

Use a simple for command, indicate all the sets of files you want to process and for each file found (referenced by %a) echo its time stamp (%~ta) and the full path to the file (%~fa)

For usage inside batch files, the percent signs need to be escaped, replacing each % with %%