[MS-Dos]List the contents of a directory in a file
Intro
It may be convenient to make the listing of one or more directories in a file, to make a catalog of files.
Under MS-DOS (or Windows by opening a window of MS-Dos) it is possible to send the output of a command to a file through redirection>:
dir c:\mydir>myfile.txt
If you want to list several directories, you just run the first command above and use it for all directories following the redirection>>, which operates to concatenate the output to the following file:
The previous method gives a list of files in one directory with all the details, but the disadvantage of adding two lines of presentation of the directory at the beginning of the result and two lines accumulating the total size of files and their number the end.
Another command gives a list of files with a path and guide to automatic sub-directories ;
Explanation
As you've noticed, dir displays the contents of a directory on the screen. The sign> means: "what is left of the sign will be displayed / recorded in what is a right of the sign."
You will not see anything on the screen, because that sign means the "show" in a text file rather than on the screen. You can do this with any DOS command (for example, mem> myfile.txt will save information on your memory to the file myfile.txt). To print directly, you can redirect the program output (stdout) to a printer, for example,
this will send the contents of the current directory to your printer who will print (if it is plugged into your port
lpt1 ...).
>> Is a special operator which deletes what is on the output device before the displaying new data.