List of files in a windows folder using CMD prompt

This method will get all the file/folder names from a windows folder to a text file
the key command here is “>” symbol, which means “create a new file with the screen output”
The syntax is :
C:\>folderpath> dir > filename.txt
Example:
Goto the command prompt from windows
C:\>
C:\>cd foldername or folderpath
C:\foldername>
C:\foldername> dir > filelist.txt
The filelist.txt will be created in the same folder of which the list of files is requested.
To change the location of the txt file
C:\foldername> dir > D:filelist.txt (now it will be created in the D drive)