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

Last update on August 24, 2009 09:57 AM by jak58
Published by netsa77

[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:
  • dir c:\mydir>myfile.txt



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 ;
  • dir /b/s c:\mydir>myfile.txt

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,
  • dir> lpt1


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.
Best answers for « List the contents of a directory in a file » in :
UNIX Commands Show Table of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
Import contacts from Excel to Outlook ShowImport contacts from Excel to Outlook Issue Solution Issue How to import a contact list from Excel to Outlook and having them in a single list of contact , and not as splited items? Solution By using the software Excel 2000 and...
Basic MS-Dos commands ShowBasic MS-Dos commands Intro The command prompts: Intro Here is a list of basic commands that you can use in a DOS prompt (e.g. a using a boot disk). To have additional information about these commands, type /? after entering the...
[Vista]Copying the results of a DOS command Show[Vista]Copy the results of a DOS command Intro Implementation Shortcuts: How to Copy the results to a text file? Intro Under Windows Vista and Windows Server 2003, the CLIP command allows you to copy the results of command in the DOS...
Linux - Tree structure of files ShowFile hierarchy under Linux To ensury compatibility and portability, Linux systems comply with the sole FHS (File Hierarchy Standard) standard. The basic hierarchy is as follows: /the root, containing the main directories /bincontains...
UNIX - Files ShowIntroduction to UNIX files In UNIX systems any element is represented in the form of a file. All files are architectured around a single tree structure where the base, called the root, is written "/". File types UNIX systems define different...
Cdantsrv - cdantsrv.exe Showcdantsrv - cdantsrv.exe The process cdantsrv.exe is part of the C-Dilla License Management Software Macrovision suite, used for digital rights management (DRM), i.e. managing access rights for copyright-protected content. The file that corresponds...