We help IT Professionals succeed at work.

How to export the list of files in a folder exported to a text file?

shyam1944
shyam1944 asked
on
Medium Priority
338 Views
Last Modified: 2012-04-14
I want to print out a list of files in a folder in to a text file, so can print the list for my an inventry record of my files.  How do I do that?
Comment
Watch Question

Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
If you want the files plus their size and date information just do:

DIR c:\dirname\*.* > "c:\save\log.txt"

If you want just a bare list of the file names then you can do:

DIR /b c:\dirname\*.* > "c:\save\log.txt"

These will list all files in the c:\dirname folder, and save the results to the "c:\save\log.txt" file.  Naturally, change the names as needed.

This command could be executed at a DOS command prompt,or in a BAT file.

To see other options on the DIR command you can do:

DIR /?

~bp
Retired
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2009
Commented:
While you can, as noted above, do this with a simple command line entry with the output directed to a text file (or printer) ,  you'll get FAR more flexibility by using a small utility designed to format and print directories.

This is a very nice free one:  http://www.karenware.com/powertools/ptdirprn.asp

... or you can look at Glenn Alcott's "Directory Printer" [Not free, but it adds a few features Karen's doesn't have]  http://www.galcott.com/index.htm
In it's simplest form, shyam1944 needs:

    DIR /B >filename

where filename is the name of the output file. This will create a list of files in the current folder.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.