A listing of a directory can be very handy for a variety of uses. You could use it to help when making backups to get a listing of filesapplications needed, to better understand the file structure, or to diff the results to monitor a directory. Whatever the use, there are two easy ways to do this and the difference of the two depends on your need and preferences.
The first way to list a directory is if you want to make a batch script and add this directory printing to a file.
dir “c:documents and settingsall usersstart menuprograms” /B /S > “H:backup08startmenu.txt”
This will put everything from the All Users Start Menu Folder into a file called startmenu.txt. It’s simply using the dir command to specify the location and then using output redirection ( > ) to point to a file instead of the screen. If you wanted to append to a file instead of overwriting one just replace the greater than ( > ) with two of them ( >> ). There are a lot of options you can use with the simple dir command to filter down the results to make them appear as you need them. From the help page (dir /?):
Displays a list of files and subdirectories in a directory.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
Specifies drive, directory, and/or files to list.
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files – Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first – Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting
timefield C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file
names. The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4 Displays four-digit years
Switches may be preset in the DIRCMD environment variable. Override
preset switches by prefixing any switch with – (hyphen)–for example, /-W.
If you’d prefer a graphical user interface, Karen’s Directory Printer v5.3.0 might be what you’re looking for. It has a lot more options than what the DIR command allows, and an easier interface to follow. The only downside seems to be that it can’t quite be implemented into scripts so easily. The source code is provided though, so perhaps any other VB6 programmer could integrate that feature.
Download Karen’s Directory Printer.