How-To Geek

How to Copy a Folder’s File List with a Right-Click

acl_top

Say you have a folder full of files, and you want to save or print a list of those files. With a couple of quick Registry edits, you can add a right-click command for copying a folder’s contents to the clipboard.

If you’ve ever needed to print or save a list of files in a directory in Windows, you know that there’s no built in command for doing so. Sure, you could try capturing a screenshot of the folder and printing that, but more than likely you won’t get all the files in the shot. You may also have resorted to using a command from the prompt to pipe the directory listing into a file, which works well enough. But why not add a simple command to the context menu you get when right-clicking a folder that immediately copies a list of the files to the clipboard? Here’s how to make it happen.

Add a Right-Click Command for Copying a File List by Editing the Registry Manually

To add the right-click command in any version of Windows, you just need to make a few edits in the Windows Registry.

Standard warning: Registry Editor is a powerful tool and misusing it can render your system unstable or even inoperable. This is a pretty simple hack and as long as you stick to the instructions, you shouldn’t have any problems. That said, if you’ve never worked with it before, consider reading about how to use the Registry Editor before you get started. And definitely back up the Registry (and your computer!) before making changes.

Open the Registry Editor by hitting Start and typing “regedit.” Press Enter to open Registry Editor and give it permission to make changes to your PC.

own_1

In the Registry Editor, use the left sidebar to navigate to the following key:

HKEY_CLASSES_ROOT\Directory\shell

acl_1

Next, you’ll create a new key inside the shell key. Right-click the shell key and choose New > Key. Name the new key “copylist.” It actually doesn’t matter what you name this key; just name it something you’ll recognize.

acl_2

Now, you’ll change the (Default) value inside the new copylist key. With the copylist key selected, double-click the (Default) value to open its properties window.

acl_3

In the properties window, set the value in the “Value data” box to “Copy File List to Clipboard” and then click “OK.” This value gives the command the name that will appear on the context menu. Again, you can type any text you want. We just recommend making it something brief and descriptive.

acl_4

Next, you’ll create a new key inside your copylist key. Right-click the copylist key and choose New > Key. Name the new key “command.”

acl_5

Now, you’ll change the (Default) value inside the new command key. With the command key selected, double-click the  (Default)  value to open its properties window.

acl_6

The (Default) value specifies the actual command that will run when you select the option on the context menu. To add a command for copying a simple list of all file names to the clipboard, type the following text into the “Value data” box and then click “OK.”

cmd /c dir "%1" /b /a:-d /o:n | clip

acl_7

Alternatively, if you want to copy a list with more details than just the file name, you could remove the /b switch from that command. This will copy the name, date, and size of files as well. Just put the following text into the “Value data” box instead:

cmd /c dir "%1" /a:-d /o:n | clip

acl_8

Since we’re calling the command prompt dir command, you could also use any of the switches that command supports if you prefer. Check out the Microsoft documentation for the dir command for more information, or just type dir /? at a Command Prompt.

Whichever command you chose, the changes should take place immediately, so you can exit out of Registry Editor. To test it out, just right-click any folder and select the “Copy File List to Clipboard” command. You might see a brief flash of the Command Prompt window opening and closing. You can paste the contents of the clipboard into the app of your choosing.

If you chose the command with the /b switch, you’ll see a simple list of files.

acl_9

If you chose the command without the /b switch, you’ll see more details.

acl_10

If you want to reverse the changes at any time, just go back into the Registry and delete the copylist key that you created. This will automatically delete any values and other keys you created inside the copylist key and remove the command from your context menu.

Download Our One-Click Registry Hacks

acl_11

If you don’t feel like diving into the Registry yourself, we’ve created some registry hacks you can use. The “Copy Simple File Names to Clipboard” hack adds the command for copying just file names to the context menu. The “Copy File Names and Details to Clipboard” adds the command for copying file names, dates, and sizes to the context menu. And the “Remove Copy File Commands from Context Menu (Default)” removes the command no matter which one you added. All three hacks are included in the following ZIP file. Double-click the one you want to use and click through the prompts.

Copy File List Hacks

These hacks are really just the copylist key, stripped down to the additional keys and values we talked about in the previous section and then exported to a .REG file. Running the hacks just modifies the value. And if you enjoy fiddling with the Registry, it’s worth taking the time to learn how to make your own Registry hacks.

Walter Glenn is a long time computer geek and tech writer. Though he's mostly a Windows and gadget guy, he has a fondness for anything tech. You can follow him on Facebook and Twitter.

  • Published 01/6/17
  • That's nice - I didn't know about using pipe to clip from cmdthanks

  • Rob Eitzen

    FYI: The initial registry navigation points to "Drive" when it really should be "Directory", as the screen shots depict. Although, both will work. Great tip! This one will really come in handy.

  • John Seiffer

    Thanks. I'd love to know how to right click on a FILE in explorer and copy it's path+name to the clip board.

  • Jim Thomas

    I, too, have been looking for a solution like this. My needs, however, sometimes require getting a list of the directories as well. So I modified the command to this:

    cmd /c dir "%1" /b /o:gn | clip

    Taking out the attribute switch and using the g order to get the directory names listed before the file names enabled this command to give me what I needed.

    I also second johnseiffer's request for a technique to copy to the clipboard the full path name and file name in Windows Explorer.

  • Biswa

    See this:: https://technet.microsoft.com/en-us/library/cc754731.aspx

    < Command> | clipclip < < FileName>

  • Walter Glenn

    @reitzen: Right you are. Thanks! I updated the article with the correction.

  • James
  • John Seiffer

    JamesEJ - Thanks. That helps. Not quite as clean as right-click but it sure does the trick.

  • Rebecca

    Windows 10 here - no clipboard - can I use 'Word' or 'notepad' instead?

  • James

    Good deal. Just in case, did you read down to the 2nd option that does not use the"dir /B > filelist.txt" but instead just this:

    Which version of Windows? In Windows 7 at least (ought to work in Win8 as well), you can select the files, press Shift and right-click. Now you'll see a new Copy as path option that you can click on, and then paste the paths in Notepad.

    Shift and right click is pretty straight forward (to me anyway). Not as clean true but not too cumbersome. Smiles, Jim

  • Preston

    Great tip. Works like a champ in Win 10!--P

  • Pradip Shah

    Will this method work on Win 10 also? At present I resort to Total Commander for the purpose.

  • James

    Preston, Yeah does work pretty nifty alright. Its good of you to let w10folks know bout it too. Jim

    https://mailtrack.io/install?source=signature&lang=en&referral=jejjamesejohnson@gmail.com&idSignature=22

  • Walter Glenn

    @HoneyReBecca: The clipboard isn't a separate app or anything. It just holds whatever you copy until you copy the next thing. After you use this trick to copy the file info, then you can paste it into anything you like. Word, Notepad, etc.

  • Mike Hazouri

    I guess I'm just old school. I've always just typed "dir >dir.txt" or use any modifiers I need when creating the text file. Bypass the clipboard altogether.

  • Dave Wingrove

    I thought this is great idea, I tried both strings and all I get now is the full files opened en mass in a word document. I thought it was supposed to give a printable list of the file docs etc from the folder. Obviously the string has too many gizmos in it as it goes too far in its operation. Very disappointment.

  • cnv

    I literally needed this a week ago. LOL.

  • Walter Glenn

    @Dave_Wingrove: I'm not sure what you mean by full files opened en mass. If you use the string from the article:

    cmd /c dir "%1" /b /a:-d /o:n | clip

    It should copy a list of filenames that you can paste into any app. It looks just like the two screenshots in the article.

More Articles You Might Like