Do you want to print a list of directory and it’s contents to a file. dir and tree command will be helpful.
dir:
dir command will list the contents of a directory.
if you want to all directories, one after the other, in alphabetical order, in wide format and pausing after each screen on the disk in your current drive,, type the following command (a.txt )
dir /s/w/o/p
dir /s/w/o/p > “a.txt” (output results to a text file )
/S : include subdirectories
/W : list in wide format
/O : alphabetical order
/p : pause after each screen
tree:
tree command will show the directory tree of the current directory
To display the tree structure of all the directory on the disk in your current drive, type: (output results to a text file )
tree > “a.txt”
tree /A > “a.txt” – Use ASCII characters
tree /F > “a.txt” – Displays the names of the files in each folder