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
    2017-04-20T18:36:10+00:00

    This didn't work for me at all. "cannot find directory path" was the result of all attempts (whether I pasted in the path or opened the command window from within the window).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-04-20T19:12:08+00:00

    This worked very well and had the advantage that in Word 2003 the categories were tab-separated which made it very easy to do a "convert text to table" and remove extraneous information by deleting the relevant columns. Thanks for the tip.

    I'm not at all fond of Firefox with all its annoying clutter and glitz (much prefer SeaMonkey even with its ever-decreasing lack of configureability) but the FF "view" option apparently isn't available in SeaMonkey.

    Was this answer helpful?

    0 comments No comments