Type the following command at a command prompt, and then press ENTER, where filename is the name of the text file that you are creating:
dir > filename.txt
https://support.microsoft.com/en-us/help/196158/how-to-create-a-text-file-list-of-the-contents-of-a-folder