Windows Tip: How To Copy A Folder’s File List From Context Menu

5

To get a list of files in a folder, you can use File Explorer to navigate to that folder, but Windows doesn’t have an option out of the box to create a list of the file names in that folder. Here is a pretty cool tip that adds an option in the Context Menu that lets you copy that list in any given folder right there.

First of all, we will need to reveal the command line used to list the file names in a folder. And you guessed it right. It’s the old school DIR if you still remember.

dir /b /a /o:n | clip

Once executed, a list of file names in the current folder, including folders, will be copied to the clipboard for further uses.

If you only need all the files in the current folder listed, you can use the following command instead.

dir /b /a:-d /o:n | clip

The “/o:n” in the command ensures the list from the folder is automatically sorted by names.

Now let’s get the Copy File List option to the right-click context menu.

Open Registry Editor and navigate to the following location:

HKEY_CLASSES_ROOT\Directory\shell

Create a new Key called “Copy File List,” just any name you want to be shown in the context menu.

Then create another new Key called “command” under the new key “Copy File List” and set the following string as the Default value.

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

Registry Editor 2017 02 05 23 11 25 600x364 - Windows Tip: How To Copy A Folder's File List From Context Menu

All set, now let’s test it out.

Right-click any folder you want to get a list of the files, and simply choose Copy File List.

Context menu with Copy File List - Windows Tip: How To Copy A Folder's File List From Context Menu

Bonus tip #1:

If you don’t want to go through the hassle creating the option in the context menu, you can still archive the same by navigating to the folder in File Explorer and run the following command in the address bar. The same list will be copied to the clipboard for you right after.

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

Bonus tip #2:

Thanks to our friend, Glenn Reimche, who shared an even better tip in the comments area below that lets you copy the file list while you are inside the folder in File Explorer.

Basically, go to the following registry location:

HKEY_CLASSES_ROOT\Directory\Background\shell

Create a new Key called “Copy File List,” or whatever the name you like to see from the context menu.

And another new Key called “command” under “Copy File List,” and set the following string as the Default value.

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

Registry Editor directory background 600x326 - Windows Tip: How To Copy A Folder's File List From Context Menu

Now, let’s navigate to a folder you want to copy the list of file names in it, right-click the empty space in that folder and choose “Copy File List.”.

Folder background context menu - Windows Tip: How To Copy A Folder's File List From Context Menu

5 COMMENTS

  1. All this time wasted not knowing I could pipe to the clipboard, thanks Kent!

    If you add the command to HKEY_CLASSES_ROOTDirectoryBackground also, the menu item will appear when you right-click on the folder’s background. (ie. after you’ve opened the folder and are looking at the contents in Explorer).

  2. Rather than pipe to the clipboard, either command can be added to a new file or appended to an exiting one. I’ve used this to create a playlist of mp3 files in a given folder. Remove the pipe to clipboard and add >playlist.m3u.

    For example: “dir *.mp3 /b >playlist.m3u”

  3. If you want the option to show only when holding Shift(+RMB) you need to add another string inside the Copy File List key and name it “Extended” without quotes.

LEAVE A REPLY

Please enter your comment!
Please enter your name here