Create a Context Menu Item to Copy a List of Files to the Clipboard in Windows Vista
If you’ve ever needed to create a list of files in a directory, you’ve likely used a command from the prompt to pipe the directory listing into a file… but what if you could simply right-click on or in any folder and copy a list of the files to the clipboard?
With some registry hacking and command line utilities, we can do just that… and we can even hide the menu item behind the Shift right-click menu so it doesn’t waste space unless you need to use it.
Using the Menu Item
You can hold down Shift and right-click inside any folder, including the Desktop, and you’ll see the new “Copy List to Clipboard” item.

You can also hold down the shift key and right-click on a folder, where you’ll also see the “Copy List to Clipboard” menu item:

Once you use the menu item, you should now have a list of files on the clipboard:

You’ll notice it’s a simple file list, there’s no file size or any other information displayed. You could modify the registry hack to eliminate the /b switch if you wanted to get the rest of the information.
How it Works
We’re actually doing here is creating a menu item that opens a command prompt, runs the dir /b command (for a clean directory listing), and then pipes that into the clip.exe utility built into Windows Vista.
First we browse down to the following registry key:
HKEY_CLASSES_ROOT\Folder\shell

We created the copylist key, and then the command key underneath that. The default value for copylist is set to “Copy List to Clipboard”, and then we set the default key for command to our command line: (Updated, Thanks Todd!)
cmd /c dir “%1″ /b /a:-d /o:n | clip
You could use the same thing from a command prompt, or in your own scripts… just replace %1 with the directory you are trying to get a listing of.
Note: If you are using Windows XP, you can download clip.exe from Microsoft. Just save the file in the Windows directory and the rest of the hack should work for you.
Downloadable Registry Hack
Naturally, I wouldn’t make you go through all the trouble of adding those keys manually, so you can download, extract, and double-click on the CopyFileListClipboard.reg file to install. There’s also a remove script included.
Just remember: you have to hold down the shift key while right-clicking in order to see the menu.
Daily Email Updates
You can get our how-to articles in your inbox each day for free. Just enter your name and email below:
| Similar Articles | Featured Wiki Articles |
|
|
| Latest Software Reviews | Quick Linux Tips |
| Geek Arcade | Popular Forum Threads |


Thank you. This is all the option I have wanted.
I’m running XP SP2 and I found that clip.exe is installed on my machine, so this tip appears to work for XP users as well. To find out if your install has clip.exe, just fire up a command prompt and type “clip”, then press [Enter]. If you get a response that says ‘INFO: Type “CLIP /?” for usage’, then you’re in good shape.
Note that the behavior of the context menu is a little different in XP. First of all, you have to click on a folder to get the option – it won’t show up if you click inside a folder. Secondly, the option will always appear in the context menu whether you press [Shift] or not.
I also have a few suggestions for other options to use in the command itself. With the /b option enabled, you can’t really tell the difference between a file name and a folder name, though usually (but not always) the files have extensions and the folders don’t. However, since the point of the tweak is to get a list of files, you may want to include the /a:-d option to exclude directories from the list. Also, I find that the dir command puts the files in whatever order it wants unless you tell it otherwise, so sorting by name with the /o:n option isn’t a bad idea either.
With those two options included, my final command looks like this:
cmd /c dir “%1″ /b /a:-d /o:n | clip
Thanks for the tip, and keep ‘em coming!
Re: ‘Create a Context Menu Item to Copy a List of Files to the Clipboard in Windows Vista’
Is there a way to do this in XP?
@Todd
That’s a very good point.. I should change the command.
I tested on XP SP2 and did not have clip.exe… I need to figure out what’s up with that.
I found a copy of clip.exe at this location
http://www.labnol.org/software.....-exe/2506/
I opened the zip into my WINDOWS folder and it seem to work as per Todd Carson above.
This trick does NOT work in Windows XP SP3. I tried following the instructions and installed the CLIP executable to the C:\Windows folder, but nothing works. It’s a no go.
This works on Windows XP SP3. I had verified it.
By the way, I did notice that it can only list one level of folder’s files.
Can we also make it to iterate all the directories contain within the specified folder? E.g. List all files and folders.
Thanks in advance.
@Leonard:
If you add a /s switch to the dir command you could display all files… note that it would probably be slow depending on where you run it from.
Cool! Thanks for the advice.
We do understand the consequences of executing this command at the root directory. This process would take quite a long time.
Anyway, I did make adjustment to the registry shown as below.
cmd /c dir “%1″ /s /b /a:-d /o:n | clip
It works too. Listing everything contain in the folder and its sub folders.
This is great, but it doesn’t list folders. I need to get a folder list copied to the clipboard.
Dave,
If you want to list only folders, change the /a:-d option to /a:d. The d means to list directories, while -d means not to list directories. Use the /s option if you want to traverse the folders below the one you’re right-clicking on and get a list of the whole tree from that folder down.
Good luck!
Todd
Just as a tip to everyone, the “dir” function has loads of command-line switches that we haven’t even gotten into in this discussion.
If you’re interested in tweaking the context menu item in ways that haven’t been mentioned, go to a command prompt and type “dir /?”. You’ll get a nice list of all the features that are available. You’ll probably want to experiment at the command prompt until you get the results you’re looking for, and then you can make the changes in the registry (if you leave the “| clip” off the end, you can see the results in the cmd.exe window instead of having to paste them somewhere else).
As The Geek mentioned, using the /s switch can take a long time if you’re starting from high up in the tree… but it can be handy if you don’t mind waiting.
Have fun tweaking the tweak!
Todd Corson
Hello again,
This is all frustrating for me. I still can’t get this wonderful solution to work in Windows XP SP3. Nothing happens. It just doesn’t execute, and I still can’t figure out why. I downloaded the CLIP.EXE file from Microsoft and placed the file in C:\Windows\. I went into RegEdit and followed the instructions exactly. It fails to work.
Geek’s solution is an excellent one. I really want to use it. What could be preventing CLIP.EXE from running on Windows XP?
@Rupertsland,
Did you hold down the shift key while right-clicking in order to see the ‘hidden’ menu?
I feel pretty embarrassed.
I finally got it working. After attempting to edit the registry manually, I decided to simply download the registry hack file and see what happens. Well, everything worked. I noticed an extra Extended key appearing under copylist that I didn’t know that had to be there. At least, that’s what I am thinking.
Anyway, now I can tweak the command further.
Please excuse my earlier whining. Thank you Geek for this great solution.
@Rupertsland
The Extended key makes the item appear only on the shift/right-click menu… I forgot to mention it in the post.
Registry editing can be tricky, that’s why I always provide the download files
@Rupertsland,
Glad that it can help you.
thanks,
Thanks for the tip! Very useful indeed, and also opens up other possibilities with the use of displaying entries with extended key (for hiding less used context menu hacks).
The dir arguments are numerous. I would suggest that for alternative versions you could rename the context menu entry and have multiple choices
E.g Copy List…. and Copy List inc Subdirs… etc.
Anyhow, thanks.
The How-To Geek is a god!
I have been doing this for a while – kind of a cut-down google of my folders and files ….. so excellent tip and writeup.
I have one question:
Is it possible to exclude a specific file and/order folder from the listing? I can’t see a specific switch for this in the dir command (the /a:-d option to exclude directories is not the same).
An example:
\Folder A
\Folder A\File 1
\Folder A\File 2
\Folder B
\Folder B\File 1
\Folder B\File 2
\Folder C
\Folder C\File 1
\Folder C\File 2
\ and so on
I want to exclude all folders/files in Folder B (i.e list all other files and folders)
Thanks.