1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hi all! No longer will threads be closed after 1000 (ish) messages. We may close if one gets so long to cause an issue and if you would like a thread closed to start a new one after a 1000 posts then just use the "Report Post" function. Enjoy!

Copying a directory of file names to a Word document

Discussion in 'Off The Beaten Track' started by Jayar, Apr 6, 2011.

  1. Jayar

    Jayar Well-Known Member

    Hi everyone,

    I have been trying to copy a huge list of file names from a directory into a Word document, and I am having trouble (I am using WindowsXP 2002). I am going into the command prompt and typing DIR /B /O:N > filename.txt. When I do this, it tells me that it is unauthorized. I am trying to copy from a drive (X) and a folder named archive. Thoughts? There are THOUSANDS of files in there, and I don't want to have to copy and paste each one.

  2. Aceon6

    Aceon6 Hit ball, find ball, hit it again.

    Have you tried the Print Directory feature in Windows? You can find the info at the Microsoft site.
  3. Artemis@BC

    Artemis@BC Well-Known Member

    Are you trying to generate editable text? (i.e., a list of filenames that you can sort by name, date, etc.) Or is simply creating a "picture" of the filenames sufficient?

    If the former ... I'm not sure it's possible. I know I've tried to do that in the past and haven't found a way. But then I didn't spend that much time trying to figure it out.

    If the latter will do, it's much easier: simply do a screen print (PrtScn) of your directory display, one screen at a time, until you get them all.

    Of course if you upgraded to Win7 it's even easier -- Win7 comes with a fabulous little screenshot tool.
  4. Aceon6

    Aceon6 Hit ball, find ball, hit it again.

    Pretty sure Jayar needs the text, not an image. Again, Print Directory may be the only hope without some wizard scripting.
  5. FigureSpins

    FigureSpins Well-Known Member

    DOS to the rescue! Old reliable is the easiest solution.

    <all programs>
    <command prompt>

    You'll get a black DOS command prompt that says C:\ (current folder) >

    1) Change Directory (command = "CD") and type the drive specification and folder name
    Example: CD C:\Users\SAMPLEUSER\Foldername
    Press ENTER

    2) Get a Directory listing (command = "DIR")and send it to a file (output director = ">") called "filename.txt" in that same directory.
    Example: DIR *.* > filename.txt
    Press ENTER

    3) To exit the Command Prompt, type "EXIT" and press enter.

    4) Once you've created the file, find it with My Computer or Windows Explorer and open it with Notepad.

    5) Copy-and-paste the text into your Word document.

    For more info on streamlining the directory listing, open the command window and type "DIR /?" or "HELP DIR" and hit ENTER.
    It will list all of the options and switches. The switches can get rid of the headers, footers, sort the list, and all sorts of other clever tricks.

    If this is a process you have to do regularly, use NOTEPAD to create a command batch file.

    Just type the commands you would have typed in the window into the Notepad document and save it with an extension of ".bat" so that it becomes executable. Then you can just locate it in its folder and double-click. The commands will be run automatically and create or overlay the output file.

    ETA: Is this the "Print Directory" process mentioned earlier? Hmmm...never used it, but it looks complicated. Is there something more simple?
    Last edited: Apr 7, 2011
  6. Aussie Willy

    Aussie Willy Hates both vegemite and peanut butter

    Figurespins - you almost make me want to use DOS. Almost.

    I might try this later.