0

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.

IGRACH
  • 3,506
  • 6
  • 33
  • 48

2 Answers2

2
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 %%

MC ND
  • 69,615
  • 8
  • 84
  • 126
1

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):

JosefZ
  • 28,460
  • 5
  • 44
  • 83
  • OK thank you this is working, but can I use files in different folders, i.e I specify path to files (3 or 4 of them), and I get only file name and modification time, files are on different locations(on network or local). – IGRACH Jun 11 '15 at 10:57