Make a List of Files

Daves99 asked the Office & Business Software forum how to insert file names into a worksheet or document.

If you want to copy one or two file names, select the file, press F2 to edit the file name, CTRL-a to select all the text, CTRL-c to copy it to the clipboard, and ESC to stop editing the file name. You can then paste the file name wherever you want it.

To grab the names of all the files in a folder, start by launching a command line window at that folder. Here's how:

If you're using XP, select Start, All Programs, Accessories, Command Prompt. At the prompt, type cd and the path to the folder you want printed. In typing the path, you can abbreviate "C:\Documents and Settings\logon (where logon is the name you log on with) to %userprofile%. In other words, instead of "C:\Documents and Settings\Dave\My Documents," simply type "%userprofile%\my documents".

This is easier with Vista and Windows 7. Navigate Windows Explorer to the folder above one you want. In the right pane, hold down SHIFT as you right-click the folder you want to copy from and select Open Command Window Here.

Once you're at the right location, type dir /b > dir.txt and press ENTER. (If you want file details as well as names, skip the /b part.) This creates a text file, dir.txt, with your directory listing.

You can load a .txt file into Word or Excel. Or you can double-click it to load it into Notepad, where you can copy its contents and paste them into just about any program.

Read the original forum discussion.

Add your comments to this article below. If you have other tech questions, email them to me at, or post them to a community of helpful folks on the PCW Answer Line forum.

11/7: This article has been altered since it was originally posted. I corrected a spelling error. LS

To comment on this article and other PCWorld content, visit our Facebook page or our Twitter feed.
Shop Tech Products at Amazon