1
Thanks

A few words of thanks would be greatly appreciated.

MS-DOS - List the contents of a directory in a file



MS-Dos - List the contents of a directory in a file


Intro

It may be convenient to list the content of one or more directories in a file. Do you require a special software for this purpose? Not really!
Using a simple MS-DOS it is possible to list the content of a directory in text file.
  • Open the command prompt and type the following command:
  • dir c:\mydir>myfile.txt
  • You can list the content of another directory in the same text file using the >> operator:
  • dir c:\mydir>myfile.txt

To have the path of each files listed as well as the organization of the sub-directories, use the below command:
  • dir /b/s c:\mydir>myfile.txt

Explanation

  • dir displays the contents of a directory on the screen.
  • The > operator indicates how to output the results of the command, in our case a text file!
  • To print this information directly, you can redirect the program output (stdout) to a printer, for example:
    • dir > lpt1
  • >> is a special operator which clear the current content of the output device before displaying new data.
1
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Original article published by . Translated by netsa77. Latest update on by jak58.

This document, titled "MS-DOS - List the contents of a directory in a file," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments