How to Copy a Folder’s File List in Windows

It may not be that often, but you may sometimes need to get the list of files in a folder. There may be several reasons such as to create a list of file names, copy all the file names, export a list of file names to excel, etc. No matter what the reason is, Windows has no default option to create a list of all the filenames in a folder. However, listing file names in a folder is not that hard in Windows. Here is how to create or copy a folder’s file list in Windows.

The first and easiest way to create a list of file names in a folder is to use the command prompt. We can just use the DIR command to export a list of file names to a text document.

To start, navigate to the folder with the files you want to create a list. Now, “Shift + right-click” in the folder, and then select the option “Open command prompt here.”

create-file-list-windows-open-command-prompt-here

The above action will open the Command Prompt in the current folder. Now, copy and execute the below command:

dir /b /a:-d /o:n > filelist.txt

As soon as you execute the command, a new text file will be created in the current folder with the list of files in the folder. The good thing about the above command is that it will only list files and ignores any directories or folders.

If you want the command to list directories or folders, use the below command:

dir /b /a /o:n > filelist.txt

As you can see from the above command, we just modified the previous command and removed the -d attribute to include folders in the list. In case you are wondering, the /o:n switch ensures that the list is automatically sorted by names.

If you need to create file lists often, then the above method may not be that user-friendly. To make things easier, you can add a context menu option which copies the file list. You can, in turn, paste the list wherever you want.

To start, search for “regedit” in the Start menu and open it.

create-file-list-windows-regedit

The above action will open the Windows Registry Editor. Here, navigate to the following location:

HKEY_CLASSES_ROOT\Directory\shell

create-file-list-windows-navigate-to-key

Right-click on the “Shell” key, and select the option “New -> Key.”

create-file-list-windows-new-key-1

Name the new key “copylist,” and press the Enter button.

create-file-list-windows-copylist-key

By default, all the new keys will have a String Value called “(Default)” with no value data. To change the value data, double-click on the value, enter the Value Data as “Copy file list,” and click on the “OK” button. This value is what you will see in the right-click context menu. Feel free to customize the text if needed.

create-file-list-windows-copy-file-list

Now, right-click on the “copylist” key, select “New” and then “Key.”

create-file-list-windows-new-key-2

Enter “command” as the name of the key.

create-file-list-windows-command-key

Again, the new key will have its own default value. To edit the value data, double-click on the Default value to open the “Edit Value Data” window. Here, enter cmd /c dir "%1" /b /a:-d /o:n | clip, and click on the “OK” button to save the changes.

Note: if you also want to list folders along with files in a folder, then replace /a:-d with /a.

create-file-list-windows-enter-command

From this point forward, you can copy the file list by simply right-clicking on the folder that contains all your files and then selecting the option “Copy file list.” Once copied, you can paste the list whereever you want, like in a Notepad or Excel sheet.

create-file-list-windows-copy-file-list-option

Do comment below sharing your thoughts and experiences about using the above method to create or copy the list of files in a folder.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.