to List All File Names in a TXT File on Windows
How to List All File Names in a TXT File on Windows
There are multiple ways to list all file names in a directory and save them into a text file on Windows. Below are different methods to achieve this using Command Prompt (CMD) and PowerShell.
Method 1: Using Command Prompt (CMD)
Follow these steps:
- Open Command Prompt (Press
Win + R
, typecmd
, and hitEnter
). - Navigate to the folder where you want to list files:
- Run the following command:
cd C:\Your\Folder\Path
dir /b > filelist.txt
This will create a text file filelist.txt
containing the names of all files in the folder.
Method 2: Listing Files from Subdirectories
To include files from all subdirectories, use:
dir /b /s > filelist.txt
The /s
option ensures that files from subdirectories are also listed.
Method 3: Including File Details
If you want additional file details such as size and modification date:
dir > filelist.txt
This will include file names along with their metadata.
Method 4: Using PowerShell
If you prefer using PowerShell, run:
Get-ChildItem -Path C:\Your\Folder\Path -File | Select-Object Name | Out-File filelist.txt
This will create filelist.txt
containing the file names.
Conclusion
These methods allow you to quickly generate a list of files in a directory and save it as a text file for reference or processing.
Comments
Post a Comment