How do I copy all file names in a folder to notepad?

Anonymous
2010-10-26T12:14:15+00:00

I often want to copy all the file names with full path and extensions in a folder to a ".txt" document but can't. Is there an easy way to do this? How? Is there a simple batch file that will do it? Freeware might work, but I would rather have a simple batch.bat or .exe file that works.

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2010-10-26T18:32:32+00:00

I often want to copy all the file names with full path and extensions in a folder to a ".txt" document but can't. Is there an easy way to do this? How? Is there a simple batch file that will do it? Freeware might work, but I would rather have a simple batch.bat or .exe file that works.

The syntax given by Steve Cochran will work but I would like to add a few comments.

First of all, the wildcard (*.*) is not needed -- the 'dir' command assumes all files & folders so it's sort of redundant in my opinion to type the wildcards.  If you choose to do so, it will not hurt anything.

Secondly, there is a way to sort the output in alphabetical order; for that the /o switch is needed.  I only mention this because, invariably whenever people ask for this kind of stuff they intend to do something with the filenames and it's much easier to deal with it if it's sorted. Another switch that I use is '/b'.  The /b switch will remove the heading information & summary so that you get just the file names.  What I normally do is:

dir "C:\some folder" > output.txt /b /o

Notice that the path for the folder name is wrapped in quotes.  You use quotes whenever the folder name or file name has a space in it.  You will also notice that there is just a single (>) as opposed to the two (>>) in Steve's answer.  The difference is that the former will overwrite the contents and the latter will append to the existing file named "output.txt".

Finally, I use the 'Open command window here' shortcut so that I don't have to navigate to the folder/directory that I want to work in.

For example if you wanted to get an output of the following folder, C:\Users{username}\Pictures\Summer Vacation

Navigate to that folder in Windows Explorer. Hold down the shift key and RIGHT click on Summer Vacation folder.  You will see a new option called 'Open command window here'.  This way, you don't have to type the full path in your dir command.

Was this answer helpful?

100+ people found this answer helpful.
0 comments No comments
Answer accepted by question author
Anonymous
2010-10-26T13:12:40+00:00

© ウィンドウズスクリプトプログラマ - Windows Script Programmer

on explorer, select all, shift + right click, copy as path. paste on notepad.

in command prompt, enter

hoge.cmd folder_path

(for %%1 in ("%~f1\*") do @echo %%1) > fullpath_hoge.txt

or drop folder on hoge.cmd

'> fullpath_hoge.txt' can be '| clip.exe'

or shortcut in sendto folder.

cmd.exe /c for /l %n in (1,1,2) do if %n==2 ((for %q in (%x%) do @for %r in ("%~q\*") do @echo %r)|clip.exe) else set x=

Was this answer helpful?

100+ people found this answer helpful.
0 comments No comments
Answer accepted by question author
Anonymous
2010-10-26T12:29:23+00:00

You can do this but I don't think it will include the entire path:

Dir *.* >> dir.txt

steve

<Roy Zeno> wrote in message news:*** Email address is removed for privacy ***...

I often want to copy all the file names with full path and extensions in a folder to a ".txt" document but can't. Is there an easy way to do this? How? Is there a simple batch file that will do it? Freeware might work, but I would rather have a simple batch.bat or .exe file that works.

Was this answer helpful?

3 people found this answer helpful.
0 comments No comments

45 additional answers

Sort by: Oldest
  1. Anonymous
    2013-10-05T09:50:40+00:00
    1. Open up a command prompt
    2. Navigate to the directory you want with cd "Documents"
    3. dir /B > filelist.txt
    4. Open filelist.txt or move it where you want.

    My output:

    C:\Users\Tom\Documents>dir /B
    all.css
    BFBC2
    Disc Images
    Fax
    Fiddler2
    gegl-0.0
    Network Monitor 3
    Scanned Documents
    SQL Server Management Studio
    SweetScape
    Virtual Machines
    Visual Studio 2010 
    

    You can limit to just files with dir /B /A-D. /AD meaning only directories, /A-D means not directories.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-10-10T17:49:16+00:00

    I Found a cool easy way to make a .bat that copies any directory windows 7: 

    1. Create a text file named "CopyFN". Inside "CopyFN" put the following without the quotation marks (spaces are ignored):

    "dir/a/-p/o:gen>copylist.txt"

    1. Open the file and go to "save as". Near the bottom where it says, file name: Change "CopyFN.txt" to "CopyFN.bat".  Below that where it says, Save as type: hit down arrow and click "All (*.*)",  then click save.
    2. This new "CopyFN.bat" file can be put or copied to any folder then double click it to run it. A new file "copylist.txt" appears that list all the files (and some garbage) from that folder.

    Let me know how it works for you. I found it in some XP notes on the web but didn't get the author's name.

    I tried this and it works wonderfully, the only problem is the whole reason I did this was that I wanted a list showing their size from least to greatest.

    Is there any way to modify this so that it gives me the notepad in the order of size instead of name.

    Was this answer helpful?

    0 comments No comments