The DIR command gives you the information you want, but it isn’t yet in a form you can use in a Windows document—you can’t copy and paste the contents of the DOS window. Instead, you’ll use another native DOS technique: output redirection. Rather than allow the DIR command’s output to appear onscreen as it does by default, you’ll send it to a text file. To do so, you’ll use the > redirection operator, like this:
dir/b /s > dirlist.txt

Of course, you can use any file name you like and you can precede it with a file path. When you press [Enter], you’ll simply see the command line reappear. However, if you close the DOS session by typing exit and you return to Windows, you’ll find a new text file that contains the file names