Q. How can I improve the speed of a DIR command?

If you have a folder that takes a long time to complete a DIR command, try using Log Parser instead. See tip 8970 » Log Parser 2.2 is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows® operating system such as the Event Log, the Registry, the file system, and Active Directory®.

NOTE: See the Log Parser 2.2 Documentation.

To perform the equivalent of a DIR on %SystemRoot%, use:

LogParser "SELECT Path, Name, Size FROM %systemroot%\*.*" -recurse:0 -i:FS -o:NAT -rtp:-1

To perform the equivalent of a DIR /S on %SystemRoot%, use:

LogParser "SELECT Path, Name, Size FROM %systemroot%\*.*" -i:FS -o:NAT -rtp:-1

The output of the above command might begin with:

Path                                              Name                                   Size
------------------------------------------------- -------------------------------------- -------
C:\WINDOWS\.                                      .                                      0
C:\WINDOWS\..                                     ..                                     0
C:\WINDOWS\$hf_mig$                               $hf_mig$                               0
C:\WINDOWS\$MSI30UninstallMSI31-RC1$              $MSI30UninstallMSI31-RC1$              0
. . . . . . .
. . . . . . .
C:\WINDOWS\AWSInstall.log                         AWSInstall.log                         616
C:\WINDOWS\basecsp.log                            basecsp.log                            3419
C:\WINDOWS\Blue Lace 16.bmp                       Blue Lace 16.bmp                       1272
C:\WINDOWS\BOOTSTAT.DAT                           BOOTSTAT.DAT                           2048
. . . . . . .
. . . . . . .
C:\WINDOWS\INF\wfp3.inf                           wfp3.inf                               3455
C:\WINDOWS\INF\wfp3.PNF                           wfp3.PNF                               8884
. . . . . . .
. . . . . . .


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish