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 you’re using the latest Windows 7, Windows XP, or even Windows 98. The best part is that it auto-generates the entire list 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.
2. In the command prompt that is displayed, Navigate to the correct folder you want. Navigation is relatively 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
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.
The Result
A file named Directory.txt is created and placed in the same folder where you just queried a directory.
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 contains every content 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.
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
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 similarly to the way keys show up in the Windows Registry Editor. From here you can print or email the organized content list quickly. Groovy eh?
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 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.
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
@Cliff
On a Mac it’s relatively similar, but you use the “ls” command instead.
Example:
ls> Directory.txt
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. http://www.voidtools.com/download.php
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.
rp
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!
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”””
MrGroove
May 25, 2010 at 9:32 am
@Ted – Great tip! We just posted a new article which covers your tip here:
https://groovypost.com/tiny/4548
Thanks again!
ZoNi
December 20, 2011 at 2:39 am
MrGroove, this link is not groovy:
https://groovypost.com/tiny/4548
;-)
click this
April 17, 2012 at 9:29 pm
Another fine post, well researched and written. You should be proud!
Geff Ratcheson
October 22, 2021 at 3:48 pm
Thank you for this. the old “list.txt” does not work on Win 10. Your suggestion of navigating to the folder and adding dir /s> Directory.txt worked perfectly. Much appreciated!