List Folder Contents In A Word Document
- 5
- Add a Comment
The other day I stumbled across a very useful trick - useful for me anyways and hopefully a few others out there. I discovered that I could list the contents of a folder in a Word document using the Command Prompt.
First, open your folder in Windows Explorer. Highlight the name of the folder in the Address bar, right click and select Copy. Next, open the Command Prompt (which you can find on the Start menu).
At the Command Prompt, type CD ” (be sure to include a space between the letter D and the double quotes), right click, select Paste and press Enter.
The Command Prompt should display the name of your folder, such as "D:\Pictures\Vacations>".
Now, at the Command Prompt, type the following command to generate the list of folder contents in a text file.
Summer DIR /ON /B *.* > D:\folderlist.txt
The /ON switch means the list will be sorted by name.
The /B switch generates a list of the filenames without the size and date/time stamp.
The “greater than” sign redirects the output of the command into the file specified (in the example above, this would be C:\folderlist.txt).
Now, open the text file in Word and you will have a list of files contained within the folder.

5 Comments
Bryan Price
September 19th, 2008
at 8:41am
Summer? Me thinks you got part of your command line prompt in there.
And here I thought you were talking about a dynamic way of getting that list in your document.
That’s a good way of getting a list of files together together to do some mass manipulation.
Although I did just have the though of a makelist.cmd
@echo off
set output=%1
if exist %output% del %output%
shift
for %%j in (%*) do echo "%%j" "%%j">>%output%
That will quote every file and double it, for you. I usually need that.
Dave
September 19th, 2008
at 9:21pm
How about Tree. It was a classic tool from msdos and is still around. You can use it to generate your output of folders and sub folders too.
Tree /F /A >C:\folderlist.txt
David Taylor
September 19th, 2008
at 9:24pm
Tree does this too but is a little different.
tree /F /A >c:\folderlist.txt
Murray Rosen
September 20th, 2008
at 11:16am
I was doing this in DOS in 1982, what’s so new about it. Other then maybe viewing the file in Word.
Mike
September 22nd, 2008
at 2:43am
Wow, that title was waaaay off!
Might just as well have described it as: just install Apache on your desktop machine, navigate to the relevant folder (no need for tedious copy-and-paste) and then save the page to disc, and open that (HTML) file from Word.
That would give you nicer formatting, too.