Windows Command Line List All Directories

Windows Command Line List All Directories

I'm looking to grab a list of the directories into a text document using a .bat file or the command line.

The problem I'm facing is that I have roughly twelve hard drives with a few folders in it, then inside those directories are around 163 more folders and I have to catalog them all. Doing this by hand would be a huge task and I'm looking to simplify it.

If you need any more information please just ask and I will provide it.

3

3 Answers

You can try different params like /s. How you will do in multiple drives is another matter. You'd end up writing a .bat file which loops through different drives and run the command below. Or simply run this from every drive and collate the results.

dir /s > fileNames.txt

The above will create a fileNames.txt with all dir names.

HTH

1

Try:

tree C: > out.txt
tree D: >> out.txt
...
tree Z: >> out.txt

You will need to do some editing, but the escape characters do help with the heirarchy.

2

You want the dir command with the flag /s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.