29 Sep

Save the list of all files in a folder in windows – recursively.


dir /s /b>FileList.txt


[tags]command, dir, directory, folder, windows, list, ls ,recursive[/tags]

## 17 thoughts on “Listing all Files Recursively in Windows”

1. Thanks! I was looking for the best way to do this.

2. dir /s /b /AD > file.txt to list folders only.

/AD is for Attribute and Directory

3. Do you know if I can apply a filter to the result? For instance, can it show only the *.txt file recursively?

4. @Rodrigo

Yes. Open a command line.
Type “cd \”
Then type “dir /b /s *.txt”

5. @logicslayer
Thank you very much!
I found the solution some months ago (my post was written in November), but thank you anyway!

6. Is it possible to filter it by size? Let’s say, I want to list the files bigger than 1 MB.

7. This is wrong (but close).
It says it “Saves the list of all files in a folder in windows – recursively”

when in fact it “Save the list of all files AND FOLDERS in a folder in windows – recursively”

how do you get a list of files only (assuming some files don’t have extentions)?

8. I am intrigued to know if you can dir *.pls recursively, I am also then looking to basically delte every pls file within this structure. However, there is 299gb and some 25k files to go through..I have a master DB of the Library but dont want all the awfully filenamed, and frankly rubbish pls files in amongst it all.

9. Is there anyway to filter out path information?

i.e. instead of e:\folder\file.txt

just output file.txt

10. For only a list of files (with paths, but excluding directories only) use the /A:-D parameter after the path (before the /B parameter)

11. Thanks!
I used
dir /s /b /AD > file.txt to list folders only
per posting number 5 above, as deleting folders via the GUI was failing on long path names.

Even the above command reported a few failures on long paths ( very long ). What is the path/filename length limitation now ( I recall 256 characters from several years ago )?

12. You could also search for:
dir /s /b C:\Windows\Temp\v*.msi

-> recursive under C:\Windows\Temp
-> files that match v*.msi

🙂 Mayra