How do you copy a list of file names in Windows XP?

This sounds like a really trivial question, but I can’t seem to figure it out.

I have 3000+ files I want to back-up on CD, and I want to keep a record of which files are on which CD. Thus I want to have a list of file names in a given folder and somehow be able to paste that into Word, but I can’t seem to be able to do it. If you highlight more than one file, you can’t copy the file names, just the actual files.

Any suggestions?

Have you tried freeware like PrintFolder?

This is a freeware application that will do what you want.

Navigate to the folder with the commander prompt and type:

dir/b > filelist.txt

Use DIR from the command prompt and pipe the output into a text file.

For example if you want a listing of all the files in c:\windwalker, go to a command prompt (Start-Run-CMD) and type:

DIR c:\windwalker > c:\output.txt

This will produce a file called “output.txt” on the root of your C drive containing a the directory listing of everything in c:\windwalker.

If you want to recurse all the subdirectories underneath c:\windwalker, add the /S switch:

DIR /S c:\windwalker > c:\output.txt

You can also do a DIR /? to see other switches (in case you need to list hidden files or whatnot).

You cannot do this from within Windows that I am aware of (at least it is not built in to Windows…some third party stuff may do it).

But you are not out of luck. You just have to do it from a comman line.

*Note: Capitalization below is for clarity and not necessary when actually typing the commands. Do NOT type quotation marks either…again for clarity below

  • Click on START>RUN

  • In the box that appears type “CMD” (or COMMAND)

This will bring you to a prompt. Chances are the directory path showing is not the one you want.

  • Chnage to the drive letter you have the directory on by typing “C:” or “D:” or whatever it is.

  • Type “CD” This will take you to the root of the drive

  • Type the path to the directory you want to list. For example: “CD download est\123” (note the “CD” command at the beginning…this is necessary)

  • Type “DIR . >C:\LIST.TXT” The “list.txt” is a filename…call it whatever you like. Note this puts the file at the root of your C: drive…you can specify another path of you like (e.g. “D:\DOWNLOAD\EXAMPLE\LIST.TXT”). Just make sure the path exists already.

That is it. You have just created a text file with the contents of your directory listed in it. Pull it inot a word processing program to clean it up.

Thanks a lot guys! Just tried the command line thing and it worked like a charm. I should probably brush up on command line stuff, as it seems you have a lot more control there.

I don’t often need to list files, but when I do need to, it’s annoying to have to go to a Command Prompt, but I worked out a little trick to make it easier. Here it is:-

Open Notepad.
Copy/Paste this text into Notepad.

Dir /b /a:-d /o:n > %temp%\FileList.txt
Notepad %temp%\FileList.txt
Del %temp%\FileList.txt

Save it as C:\WINDOWS\system32\FileList.bat

Be sure to specify the .bat extension.
This creates a batch file that will (1.)List the files in a Directory, and write that list to a text file in the Windows Temp Folder. (2.)Open the file in Notepad, where you can view, edit, and “Save As…”, or print out, etc. (3.)Delete the file when you’re finished (When you close Notepad)

Now, you can use this from the Command Prompt, (Just type “filelist”, and up pops Notepad with a list of the files in the Current Directory) but there’s a simpler way to use it - hook it up to your Right-Click Menu. Here’s how:-

First, create a System Restore Point using Microsoft’s System Restore. (Just in case something goes wrong)

Now, open Windows Explorer

  1. In the Menu Bar click “Tools > Folder Options…”
  2. In the Dialog Box click the “File Types” tab
  3. In the list of Registered file types, select “Folder” (NOT “File Folder”)
  4. Click the “Advanced” button
  5. Up comes the “Edit File Type” dialog box
  6. Click the “New…” button
  7. Up comes the “New Action” dialog box
  8. In the Textbox labelled “Action:” type “File List to Text”
  9. Click the “Browse…” button
  10. Up comes the “Open With” Dialog box
  11. Browse and select “C:\WINDOWS\system32\FileList.bat”
  12. Click the “Open” button
  13. The “New Action” Dialog Box will now show “File List to Text” and “C:\WINDOWS\system32\FileList.bat”
  14. Click “OK” in the “New Action” dialog box
  15. Click “OK” in the “Edit File Type” dialog box
  16. Click “OK” in the “Folder Options” dialog box
    Now you’re back in Windows Explorer

In the Drive/Folder tree on the left, Right-Click on a Folder. One of the Menu options will now be “File List to Text”, click that, and (1)A Command Prompt window will open, ignore it, (2)Notepad will open with a list of the files in the folder that you Right-Clicked. Do whatever you need with the list, (Save As… to keep a copy somewhere, or print it out, etc). When you’re finished, close Notepad, and the Command Prompt window will close as well.

A few points to note. The file “C:\WINDOWS\system32\FileList.bat” must be created using Notepad, or some simple text editor. It will not work if you create it in MS Word, or any rich text editor.
The first line of the batch file - “Dir /b /a:-d /o:n” creates a Directory list in Bare format (/b), does not list folders (/a:-d), and sorts by name (o:n). It will not list files in subfolders, if you do want it to go into subfolders, add /s. If the output format is not to your liking, you can change it by changing the switches. You can get info on the various switches by typing “dir /?” at a Command prompt
In the OP, you mentioned that you want to use Word. I use Notepad because it serves my simple needs, but if you want to open FileList.txt in Word, change the second line of the batch file from “Notepad %temp%\FileList.txt” to “Word %temp%\FileList.txt”. That should work, but I haven’t tried it.
“File List to Text” is now part of your Right-Click menu for Folders, it also shows up when you Right-Click on a Drive icon.

Hope that helps

One slight correction to rockystone’s excellent suggestion. If you do want to open the resulting file list in Word, change the entry “Word %temp%\FileList.txt” to “winword %temp%\FileList.txt”.

Dang. Just to get a filelist?

:confused:

Hmm…I think we have a different definition of “easier.” :wink:

rockystone’s suggestion is to setup Windows to get a list easily anytime you need it. (It’s also a good lesson in using Windows). If this is a onetime thing then obviously you’ll want to use one of the simulposts that came earlier.

My “Dang” wasn’t intended as a response to just one of these cumbersome procedures.

When I want a filelist of all files in a folder, I select all, copy (standard “copy” keystroke), then paste wherever I need the filelist to appear.

Call me naive, I thought all computers worked that way now.

To tweak these soulutions, you can even save yourself the command step and run these commands directly from Start->Run:



cmd /c DIR c:\windwalker > c:\output.txt
cmd /c DIR /S c:\windwalker > c:\output.txt


If I Copy several files and then Paste them into a new file, how can the operating system know whether I mean to copy only the titles of the source files (as per your example), or the contents of the files (which seems just as likely), or some other equally plausible aspect of them? Maybe you computers are telepathic.

I guess mine is. It knows to paste the actual files themselves if I’m right-clicking and going Command-V in a folder or at the root of some disk, whereas if I’m in a word processor or the body of an email, it knows to paste the names instead.

a) mine is a Mac

b) this is not intended as a “ha ha stoopid Windoze users” post. there are things the MacOS doesn’t get right, also — for instance, someone was complaining that they couldn’t drag all the files from a folder on one volume to a similar folder on another and have it only actually replace the ones that were newer. Nope, MacOS X will alert you to the fact that there are duplicates, and ask you if you want to replace, but it won’t tell you which ones are newer, let alone just automatically replace the older ones with the newer ones while leaving the newer ones intact and not overwriting them with older ones of the same name, etc.

I tried Ahunter3’s method just now using XP Windows Explorer and Word. I opened my “Literature” folder, because it’s all text files like .doc or .rtf or .txt.

Control A (select all). Control C (copy). Open Word and Control V (paste).

Result: something strange. I got no filenames. Instead I saw the fulltext of only the first page from the first file in the directory. The title bar called it “Document 1” instead of the real filename. The window could not be scrolled, clicked, cursored, or edited. When I tried clicking on it, advice was displayed: “Double click on this window for editing.” When I did, a new Word window opened with the normal editable text.

The first thing I got was just a big preview image, just like the teeny preview panel seen in the Open File dialog box, but larger. Well, this is a feature of Windows that I had not known existed.