Recursive directory listing in DOS

322,770

Solution 1

You can use:

dir /s

If you need the list without all the header/footer information try this:

dir /s /b

(For sure this will work for DOS 6 and later; might have worked prior to that, but I can't recall.)

Solution 2

dir /s /b /a:d>output.txt will port it to a text file

Solution 3

You can get the parameters you are asking for by typing:

dir /?

For the full list, try:

dir /s /b /a:d

Solution 4

You can use various options with FINDSTR to remove the lines do not want, like so:

DIR /S | FINDSTR "\-" | FINDSTR /VI DIR

Normal output contains entries like these:

28-Aug-14  05:14 PM    <DIR>          .
28-Aug-14  05:14 PM    <DIR>          ..

You could remove these using the various filtering options offered by FINDSTR. You can also use the excellent unxutils, but it converts the output to UNIX by default, so you no longer get CR+LF; FINDSTR offers the best Windows option.

Solution 5

I like to use the following to get a nicely sorted listing of the current dir:

> dir . /s /b sortorder:N
Share:
322,770

Related videos on Youtube

StarDotStar
Author by

StarDotStar

Updated on November 23, 2021

Comments

  • StarDotStar
    StarDotStar over 2 years

    How do we achieve a recursive directory listing in DOS?

    I'm looking for a command or a script in DOS which can give me the recursive directory listing similar to ls -R command in Unix.

  • Steven Magana-Zook
    Steven Magana-Zook about 11 years
    +1 very handy. If your directories contain lots of files, then this command will scroll them by on the screen too quickly to read. I think it is best to pipe the output of this command to a txt file you can read at your own speed. For example (assuming c:\temp directory is created): dir C:\ /s > C:\temp\CDirectoryListing.txt
  • Walialu
    Walialu over 10 years
    You sir, are seriously awesome! It worked like a charm! I used it at work (where we are forced to have windows machines) with gVIM! Really, really good! You saved me hours of headache!
  • kungfooman
    kungfooman over 10 years
    For some reason it prints the full absolute path with C:\folder in front when using /S and /B, is that preventable? I only want the relative filename.
  • Michael Todd
    Michael Todd over 10 years
    @lama12345 Not that I know of. I guess you could pipe the results to a text file and then remove the relevant path via a text editor though.
  • kungfooman
    kungfooman over 10 years
    Yep, works perfect with Search/Replace "C:/folder" and replace with "".
  • arun
    arun almost 10 years
    Just to add: tree /f gives a pleasing display to the eye :-)
  • domih
    domih almost 7 years
    Nice! My additional requirement is to count all the lines, which is done with dir /s /b | find /v /c "".
  • bobroxsox
    bobroxsox almost 7 years
    @StevenMagana-Zook Add the /p switch to make each key press scroll 1 page. dir /s /p