Link to home
Start Free TrialLog in
Avatar of WeThotUWasAToad
WeThotUWasAToad

asked on

DOS command to list both directory AND subdirectories

Hello,

I have almost no knowledge of DOS but sometime ago, an helpful EE Expert provided me with a DOS command which creates a text file of a folder's directory. The command is as follows:

      Dir "C:\Users\Username\Folder name" > "C:\Users\Username\Folder name\List.txt"

I have found this command to be a great tool and have used it multiple times.

When using this command, I've noticed that when the directory contains a subfolder, the subfolder name is included in the resulting .txt file with the preceding label: <DIR>, but no subfolder contents are included.

Is there a way to modify the above DOS command so that it will display not only subfolder names but their directories as well?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bartender_1
Bartender_1
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you wanted to show only the directory names, you could try this:

Dir "C:\Users\Username\Folder name" /s /AD > "C:\Users\Username\Folder name\List.txt"

Hope this helps!

:o)

Bartender_1
Tree command should do what you are looking for

At the command prompt enter the following

Tree > c:\tree.txt

When the execution is completed, check c:\tree.txt file

Regards
To add slightly to that...

CD c:\startdir
Tree /f > c:\somewhere\lust.txt

Will show all files in the tree too.

Steve
Hi We...Toad,

> display not only subfolder names but their directories as well

By "directories" above, I'm assuming you mean "files" (or "contents"). Just add the "/s" option. In other words:

Dir "C:\Users\Username\Folder name" /s > "C:\Users\Username\Folder name\List.txt"

Regards, Joe
Avatar of WeThotUWasAToad
WeThotUWasAToad

ASKER

Thanks for the detailed answer.