List files recursively with cmd in folders and subfolders

List all the files contained in a folder and its subfolders recursively with a cmd script.

Per default, use the cmd tool with the dir command allows to list all files and folders within a given folder, but not recursively. To display a complete of files and optionally folders within all the subfolders, use the dir command options as follows.

Cmd scripts to list Windows files recursively from a folder and its subfolders

With a ms dos prompt, to list all the files inside a folder. To do so, type the dir command to list the folder content with the recursive dedicated option. The command below displays the files inside a folder and all subfolders, recursively. Indeed every folder has a list of files, with its subtotal of file counts and size.

dir /s

To get a list of files recursively in a single list with o split between each subfolder, type this cmd command:

dir /s /b

The command displays all the files and folders in the current folder and all its subfolders. To list only the files and not the folders, use this command.

dir /s /b /a-d

The /a option is an attribute filter. Then the -d option means minus folders, then the folder are not displayed in the command prompt.

Tutorials to manage Windows files with cmd and powershell

Scroll to Top