Looking for DOS command to create file listing of a folder and its sub-folders into a text file? Here are the simple steps.
Before using the commands, do below steps
- Open Command Prompt
- Goto the folder path from where you want to list the files.
- Run below commands
In below examples, C:\Main-Folder\Folder> is the folder path
dir > is the command
C:\Main-Folder\list.txt is the path for output text file. The text file will be created automatically, if it doesn’t exist.
Case 1: DOS command to list files in a folder
Command : dir >
Example:
Output: list.txt file
Case 2: DOS command to list files in folder and its sub-folders
DOS Command: dir /s >
Example:
Output:
Case 3: Listing only specific type of files
Suppose if you want to list only .txt files, then use below command.
dir /s *.txt >
Example:
Output:
Notes:
1.If you have spaces in file name, then you will see “File Not Found” error. Don’t worry, just ignore that. Text file and file listing will be created.