Top Nav

List Directory Contents To A Printable and Readable Txt File [How-To]

Need to know exactly what’s on a computer and want to look at it from a glance or a printed directory version?  The command prompt (DOS CMD) has been existent since the beginning of Windows, so this groovy trick will work no matter if your using the latest Windows 7, Windows XP, or even Windows 98.  The best part is that the entire list is automatically generated for you.


How To Automatically Create A Text Document Directory Listing Of Any Folder In Windows

1. Click the Windows Start Menu Orb and Type in cmd.  Once the program link appears, Right-Click cmd.exe and Select Run as administrator.

open command prompt in administrator mode

2. In the command prompt that appears, Navigate to the correct folder you want.  Navigation is fairly simple, just type “cd” (change directory) and then the local location of the folder on your computer.  For example if I wanted to go to c:Program Files, I would just Type:

cd c:program files

use cd in command prompt to change directory

3. Once command prompt is at the folder you want a directory of Type in the following:

dir /s> Directory.txt

Tip:  Add /b like in the screenshot below if you don’t need file details such as size, or date to be included.

use dir /b /s > directory.txt to output a dir query to a text file

The Result

A file named Directory.txt will be created and placed in the same folder you just queried a directory of.

a directory.txt file is created on your windows system

Inside of Directory.txt will be a complete list of every file within the queried location.  In this example I have a HUGE list of every folder and file in c:program files, and the list gets even bigger as it lists every the contents of every folder within every folder and each file in those.  In this way you can view every single file from any parent location in Windows in an organized and printable format.

Related Article:  Windows 8: Find How Long Your System Has Been Running

a complete list of all contents in a directory including a sub-folder and sub-files

The Tree Alternative

If you are more of a visual person, then the tree format may better suit your needs.  This command works similar to the above one.

Just follow the above instructions, but at Step #3 rather than typing “dir /s> Directory.txt” instead Type:

tree> Tree.txt /A /F

using the tree command in windows 7

The Tree Result

A Tree.txt file will be generated and placed in the same directory.  This Tree format will display the same information as the other Directory, but it will be organized similar to the way keys are shown in the Windows Registry Editor.  From here you can print or email the organized content list easily, groovy eh?

a printable tree of every file on your system in the specified directory

The Prompt (DOS) Commands Explained

Command Sub Command Explanation
cd Aka change directory, used for basic navigation in DOS.
dir Displays all contents of the current directory
/s When added after dir will display subdirectory contents
/b Makes dir display only basic or “bare” file information
> > Is an interjectory value that forces command output to an external file or location. Useful for any query.
tree A graphic version of dir
/a Provides a ASCII graphics
/f Makes tree display file names

Questions, Thoughts?  Post a comment below and check out the free groovyPost RSS feed for daily tech-related tips, how-to, and news.

More Reading:

, , ,

8 Responses to List Directory Contents To A Printable and Readable Txt File [How-To]

  1. Cliff May 13, 2010 at 10:40 pm #

    Anyone know how to do this on a Mac?

    • grooveDexer May 14, 2010 at 11:51 am #

      On a Mac it’s relatively similar, but you use the “ls” command instead.
      ls> Directory.txt

  2. Roger Pence May 13, 2010 at 11:16 pm #

    This is a good tip, but there is a terrific free utility that is much better for tracking and finding files: It’s called Everything by VoidTools.

    I am in no affiliated with VoidTools, just a very happy user. I used to use tricks like your article explains, but now with EveryThing you can quickly find (by pattern) any file on your system _very_ quickly.

    • MrGroove May 14, 2010 at 10:54 pm #

      Thanks Roger. Will check it out. If it’s work a write-up perhaps we will do a review on it (unless you want to do a quick writeup?). Thnx and welcome to groovyPost!

  3. Ted Levinson May 14, 2010 at 12:46 pm #

    Here are the REG keys to make this a right-click mouse function.

    HKCR,”Drive\Shell\Command Prompt Here\command”,,,”%11%\cmd.exe /k cd “”%1″””
    HKCR,”Directory\Shell\Command Prompt Here\command”,,,”%11%\cmd.exe /k cd “”%1″”” ; Add “command-prompt-here” functionality when right-clicking a directory
    HKCR,”Folder\Shell\List Contents to text file\command”,,,”%11%\cmd.exe /C DIR “”%1″” /B /O /S>””%1″”””_contents list.txt”””

  4. click this April 17, 2012 at 9:29 pm #

    Another fine post, well researched and written. You should be proud!

Leave a Reply