Search code examples
windowscmdwindows-xpwindows-2000

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


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.


Solution

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