March 22, 2008

Print Folder Contents in Text File

Open a command prompt. Change directory with the cd command to get into the directory you want to read. Then type this command.

dir /a >c:\dirlist.txt

The "dir" command will read the current directory.
the "/a" tells "dir" to read all files in the folder, even hidden or system files.

Then the ">" (greater-than sign) tells "dir" to redirect its output to the filename following.

"dirlist.txt" is the name of the file that will receive the directory listing.



I use this simple technique often to get a listing of files in some folder or another.

[If using the CD command to change to a specific directory is not to your liking, you can just insert the path to the subject folder in the command line, like this:

dir /a "C:\Program Files\xorb\" > C:\dirlist.txt
This will list all the files in the \xorb\ folder.]

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...