Recursive directory listing in DOS

DosDirectory Listing

Dos Problem Overview


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.

Dos Solutions


Solution 1 - Dos

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 - Dos

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

Solution 3 - Dos

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

dir /?

For the full list, try:

dir /s /b /a:d

Solution 4 - Dos

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 - Dos

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

> dir . /s /b sortorder:N

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStarDotStarView Question on Stackoverflow
Solution 1 - DosMichael ToddView Answer on Stackoverflow
Solution 2 - DosTribrachView Answer on Stackoverflow
Solution 3 - DosFortiusView Answer on Stackoverflow
Solution 4 - DosZeinab QureshiView Answer on Stackoverflow
Solution 5 - DosLove and peace - Joe CodeswellView Answer on Stackoverflow