Question:
batch job. create a list of ALL folders on a system?
Netiad
2007-04-23 19:25:20 UTC
i need a batch file that when run on any windows operating system will create a text file of ALL folders.

not just dir /s >> textfile.txt

This needs to be in a for loop and when run ONCE it creates a list of ALL directory paths. Therefore the shouldn't be any cd command because we don't know the exact path of say c:\tim\fun
Three answers:
Kevin
2007-04-25 16:42:30 UTC
Using the "for" command is one option. Here's an easy one using the "dir" command with a few switches,



dir \ /s /b /ad > textfile.txt



"\" = start from the root directory

"/s" = get all subdirectories

"/b" = bare information, just names

"/ad" = just get directories
schrey
2016-12-27 02:25:09 UTC
attempt from the c: instantaneous dir *. >dirlist.txt Folders have not got an extension to their call, as a result *. will instruct wildcard DOT entries contained in thechronic the report is parsable in a application if choose be, as i've got executed it as quickly as earlier. you additionally can use any of the DIR command switches. the > directs the output to the report named.
Amanda H
2007-04-23 19:52:09 UTC
cd \

for /d /r %x in (*) do echo %x >> textfile.txt



dont forget to use %%x if running from a batch file.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...