# Listing all Files Recursively in Windows

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]

Author: Binny V A
A philosopher programmer who specializes in backend development and stoicism.

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

1. sathya says:

It was very useful and it is the simple way to list all the dirs recursively. Awesome.
Thanks

2. milind says:

thanks.. helped a lot..

3. Martin says:

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

4. bla bla says:

how about only listing folders recursively?

5. Anon says:

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

/AD is for Attribute and Directory

6. Rodrigo says:

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

7. @Rodrigo

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

8. Rodrigo says:

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

9. Anuj says:

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

10. :( says:

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)?

11. Sean Uddin says:

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.

12. Mark Balcerak says:

Is there anyway to filter out path information?

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

just output file.txt

13. Thakulf says:

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

14. Rick Dallow says:

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 )?

15. Mayra says:

Hello Rick, try option “/x” to use the short 8.3 names, perhaps this works

16. Mayra says:

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

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

🙂 Mayra

17. Shashank says:

Is there any similar command for ftp recursive file listing ?