select to copy files or folders to excel

Copy file and folder names into Excel

How to copy-paste file names or folder names into Excel

Here you will learn how to copy a list of file names into Excel and also how to copy folder names into Excel. First you start with a list of folders or file names. Though it’s not obvious how you copy those names, you can do it in two main steps. Unless you know how to, it’s hard to see how to get just the list of names instead of copying the files themselves. That is what you get if you just select and click copy. Not obvious but it is simple and I’ll break it down so almost anybody can do it! Read on.

Contents (click to jump to the section that you need)

Introduction

How to Copy file names into Excel (or text file)

Copy all file names in a folder Windows 10

How to Paste into a text file

Special formula to cut pasted filenames

How to Copy folder names into Excel (or other app)

Copy multiple folder names

Formula to cut pasted folder name paths

Summary

Introduction

You might need to get a list of folder names or file names into another useful place, like excel or a text file. Let’s say you have your list already. It might be all folders on your PC for example, or more likely a list of sub-folders.

Now you want to export those to another program, like MS Excel (although you can use other programs for the destination).

You select the ones you want, click copy, and… Uh-oh, no you have just copied all the files or folders (not the names). You can’t past those into an Excel sheet or a text file.

Seems impossible, but there is a sneaky yet easy way to do it.

We will answer the question “how do I copy a list of filenames into excel?” 

In other words, “how to export file directory to excel” when you are asking for the files which are contained in a directory in Windows.

After, we’ll show how do it with a list of folder names.

How to Copy File Names into Excel

We are going to walk you through the process so anyone can follow it step by step.

If you know most of how to do this, you should be able to skim read just the highlights.

If you are an expert, here it is, super short:

  • Select multiple files (or just one).
  • <Shift> + right click on a selected file.
  • Select ‘Copy as Path’
  • <Ctrl> + <v> into Excel
  • Use my formula to easily trim path from list of filenames with path.

Click here to jump direct to the formula.

As that probably isn’t detailed enough for most people, read on to see it step by step.

Step 1 Select the files you want to copy in your list of file names

Open ‘My Computer’ (or ‘This PC’) and go to the files you want.

You can select just one file or multiple file names.

There are many way to select multiple file names.

For example, you can click and drag the mouse over the ones you want.

how to copy file names into excel

This image shows how to copy file names by selecting them (with click and drag) to paste into Excel at a later step.

Copy all file names in a folder Windows 10:

You can hit <Ctrl> + <a>.

The ‘a’ is to select and copy all file names in a folder in Windows 10 – that is hold down the ‘control’ and tap the ‘A’ key for the letter ‘a’.

It is the same shortcut to select all items (not just files) within any directory and many views of items in all versions of Windows, it seems.

Alternatively if you want a specific selection of your file names do this: Press <Ctrl> and click on each individual file to select just the file names you want. You can click again to deselect one.

There are many more ways to copy filenames from Windows Explorer, once you have selected them using the above step.

You can sort the list by clicking the header as shown below – either by alphabetically (Name) or by Date when in the ‘Details’ view (rather than icon view). To see the ‘Details’ view, look at the top, for the ribon and click ‘View’, and then ‘Details’.

copy all file names in a folder windows 10

Use the Control key and the ‘a’ key to select and copy all file names in a folder in Windows 10. You may like to sort by Name or Date first. Note the date information won’t be exported to Excel via this method. The next part of how to copy the file names follows below.

If you don’t want all the file names, with the list sorted you can select adjacent files by first clicking on the end of the range of files names you want, then hold <Shift> and click the other end of the range of filenames in your list.

There are many ways to do it. I guess you get the picture and may have your own preferred way.

If you have the particular case of wanting to select from a search for specific files see Save Explorer Search Results to Excel.

So we have selected all files, next to copy the names not the files.

Here is how to copy the file names (not the files).

Step 2 Copy File Names

This is a special way to copy your selection so you get the names and not the whole files.

Press <Shift> + Right-Click.

To be clear, that is press the <Shift> key and while still pressing it, then click the right mouse button on any of your selected file names (any file will do if all files are selected).

This shows a less often viewed pop up menu.

In this menu options list scan down to find “Copy as Path”. See below for an example.

shift key and right click gives this menu with Copy as Path

Copy file names using Copy as Path to be sure to copy the names (not the full files) to the clip board ready to paste into Excel.

Now, if you can’t see it, remember it should be there if you hold down the shift key when you right click. Look closely at the screen copy for how it looks in Windows 10.

In Windows 7 and Windows 8 this pop up menu will look a little different, but the shift right-click menu contains ‘Copy as Path’.

So again, just to be clear, if you do not see ‘Copy as Path’ in your pop-up options, check again if you still have <Shift> held down when you clicked the right mouse button on a selected or highlighted file.

TIP: If you find you didn’t have the <Shift> key held down, simply hold shift now and right-click on one of your already selected file names (away from the menu that already popped up) so that your file selection remains selected. This just saves you having to select multiple file names again. Remember this one because it’s common to forget the first few times you do it after you learn it here.

Now, how to copy file names into excel, to complete the copy paste into excel (or text file).

Step 3 Paste into Excel or Text File

I cover here how to copy multiple file names into excel and also as an alternative I cover how to paste into a text file instead. You could paste into Microsoft Outlook or other email program, Google docs, or what ever software you have with a text editing field.

Go to your excel file and select where you want to paste. Make sure there is nothing below the selected sell that you wouldn’t want pasted over.

Press <Ctrl> + <v>.

That is hold down the control key and then press the letter v.

That is a shortcut, and there are many other ways to paste.

If you don’t like using short cut key combinations, you can use the click the icon with the image of the clipboard (often with Paste written under it).

Another alternative is to right click and then paste (use the paste icon).

More than just a list of file names?

NOTE: Do not worry when you see there is more stuff in there than just the file names! At this point the file path as well as the file name will be pasted. The next step will help you clean that up to leave only the file names if that is all you need.

To paste into a text file:

Open an existing text file, or start a new one. You will need Notepad or other text editor. If you don’t know how to do this, one way is to start Notepad. Since Notepad is included in every version of Windows, we’ll demonstrate with that.

Windows 8: Swipe down from the right and start to type Notepad in the search.

Windows 10: In the search bar (normally at the bottom of the screen, unless you moved it!) start to type Notepad. Only the first two or three characters are likely to be required for Windows to respond by showing the Notepad app.

Click on the Notepad icon and you are away!

Step 4 Tidy up the list of file names pasted into Excel or Notepad.

As you will now see, whether you have pasted a single file or multiple file names, they all come with the location of the file too.

If you don’t have a big list of files, you can manually edit them. Yes it might take a little time, but you will have completed your task to copy and paste a list of file names into Excel.

Before you groan, if you have a huge list of file names (or even a few and you are lazy like me) I have a brilliant secret formula that will cut out everything except the file name. I’ll show that secret too!

So, you can click in the Formula bar at the top of each cell in turn, then delete the unwanted file path manually, leaving only the name.

Or, you can double-click on the excel cell and edit the text in the cell.

Or you can use the function key <F2>.

Just find the function keys near the top of your keyboard and press ‘F2’.

Either way, you can select the unwanted part of the text before the file name itself, by clicking and dragging the mouse.

Or you can press arrow keys to get the cursor when you need and tap delete, delete, delete, delete, … etc.!

Special formula to cut pasted filenames

Here is one great advantage of using Microsoft Excel when you do copy file names into Excel this way.

Excel can automatically trim your list down to just all the files names only for you.

If you are not familiar with Excel formulas, this can work for you, but you will need to have pasted the file list in Cell B2. Maybe you will want to start a new Excel sheet so there is nothing else in there, if that is the case.

Click here to download an excel file with the formula and examples.

You can copy and paste the formula from there.

If you don’t want to download the file, you can do the following:

Copy from this website and Paste my PARTIAL formula below into Excel (I suggest Cell A1).

See also the note further below.

=TRIM(RIGHT(SUBSTITUTE(B1,

Then continue to write the rest of the formula as per the image below.

part of formula to get filenames in excel

Those are Excel formula quotes! Strange (or clever?) formula is it not?!

NOTE: Why did I show the formula like this? It is because you need to be sure you get the Excel formula quote marks into the formula. This blog automatically changes formula quotes to curly or ‘smart’ quotes. A good way to be certain the formula works is to type it direct into Excel yourself (sorry!). If you copy and paste from a website, sometimes you get the ‘fancy’ 66-99 version of quote marks (or otherwise modified quotation marks which are not suitable for excel) which will stop my formula from working (even if they don’t look different)!

As stated above, to use my formula without any alterations, you will need to have pasted your file list (and paths) into cell B1.

If you are familiar with excel formulae, you can paste wherever you need and edit my formula to suit.

That will be easy if you have a basic understanding with Excel formula cell references.

Do not worry, you do not need to know much about formulas or understand this one in particular. Just paste it (preferred) or type it in (less preferred in case you mistype it).

The final formula to paste into Cell A1 with additional typing should look like:

Formula to extract filenames in Excel in cell A1 wit reference to cell B2.

Now you can copy and paste this formula next to every file name and path in your list.

Again, as with all things Excel, there are many ways to do this.

What to do when Pasted Into Text File:

If you pasted into a text file, the only way is to manually edit the file name and path to leave only the file name.

If you really have many to edit, you could paste into excel, use my formula as above, and then copy that list of file names into a text file.

How to Copy Folder Names into Excel

We are going to walk you through the process so anyone can follow it step by step.

If you know most of how to do this, you should be able to skim read just the highlights.

If you are an expert, here it is, in brief:

  • Select to copy multiple folders.
  • <Shift> + right click on a selected folder.
  • Select ‘Copy as Path’
  • <Ctrl> + <v> into Excel
  • Use my formula to trim path.

Click here to jump direct to the formula for a list of folders.

If that isn’t detailed enough, read on to see it step by step.

Step 1 Select the folders you want to copy in your list of folders

You can select just one folder or multiple folder names.

To select just one folder, just click on it.

How to copy multiple folder names into Excel

There are many way to select multiple folders to get their names into MS Excel.

For example, you can click and drag the mouse over the ones you want.

It’s basically the same as shown above when selecting file rather than folders.

You can hit <Ctrl> + <a>.

The ‘a’ is to select and copy all folder names (sub-directories) within any folder Windows 10 – that is hold down the ‘control’ and tap the ‘A’ key for the letter ‘a’.

Alternatively if you want a specific list of only a few of your sub-folder or folder names do this:

Press <Ctrl> and click on each individual folder to select just all the folder names you want. You can click again to deselect one.

I guess you get the picture and have your own preferred way (there are many more).

For the special case of having to select from a search of specific folders see this article using File Explorer search results.

Next we show how to copy the folder names (not the folders with their actual files contained within).

Step 2 Copy Names of Folders to Clipboard

We use a special way to copy your selected folders.

Press <Shift> + Right-Click.

To explain in painful detail, that means hold the <Shift> key and while still pressing it, you hover the mouse over any of your selected folder names (any folder will do if all folders are selected) and right click.

This shows pop up menu that has what we need.

In this menu options list scan down to find “Copy as Path” to copy selected folders. See below for an example. Your menu could be diffent and Copy as Path could seem a long way down the list.

Copy folder names into excel with Copy as Path.

 

It will be there if you have held down the shift key when you clicked the right button. Check the image or the screen copy for how it should look in Windows 10.

Note: In Windows 8 this pop up menu will look a little different, but the shift right-click menu contains ‘Copy as Path’.

Note: In Windows 7 or Vista, the menu can look simpler, but the <Shift> and right-click combo will still contain ‘Copy as Path’.

To be clear, if you do not see ‘Copy as Path’ in your pop-up options, I remind you to hold <Shift> down when you click the right mouse button on a selected or highlighted folder.

TIP: If you find you didn’t have the <Shift> key held down, simply hold shift now and right-click on one of your already selected folder names (away from the menu that already popped up) so that your folder selection remains… well… selected! It could save having to select multiple file names again. Although minor, it’s a great tip because I found I forgot the first few times when I started to apply it. Believe me, it is a pain when you have painstakingly picked out several in a big list of folders!

So we have the folder names on the computer ‘clip board’, next how to copy this list of folders into excel, to complete our copy paste combo.

Step 3 Paste Folder information into Excel

I cover here how to copy all folder names into Microsoft Excel. But you can put them wherever you like, MS Word for example.

Select the Excel file and select where you want to paste. If starting a blank sheet, I suggest cell B2.

Warning: If you are not pasting into a blank Excel file, then be sure to avoid a location where you have other data etc.

Press <Ctrl> + <v>. 

Yup, you guessed it, hold down the control key and then press the letter ‘v’.

There are many other ways to paste.

For example, click the icon with the image of the clipboard (often with Paste written under it).

I often right click and then select paste.

More than just a List of Folder Names?

Note: each cell will show the full path to the folders, not just the final sub-folder names! 

We next clean that up to leave only the folder names. You can skip this if you want a full list of all folder names to each folder location.

Step 4 -Tidy up the list of Folder Names pasted into Excel

As you will now see, whether you have pasted a single folder or multiple folder names, they also come with the location of that folder.

If you don’t have a big list of folders, it is pretty easy to manually edit them. Yes it might take a little time, but you will have completed your task to copy and paste a list of file names into Excel.

Note that if you have a big list of folder names (or even a few and are a little lazy, or simply like to try new things) I have a brilliant secret formula that will cut out everything except the last part of the path leaving only the final (sub-) folder name. I’ll show that secret too!

You can click in the Formula bar at the top of each cell in turn, then delete the unwanted file path, leaving only the name.

Instead, I often use the function key <F2>.

For that shortcut Just press ‘F2’ near the top of your keyboard.

Or, you can double-click on the excel cell and edit the text in the cell.

Anyhow, you can select the unwanted part of the text before the file name itself, by clicking and dragging the mouse.

True, you can put the cursor where you need and tap delete, delete, repeat, repeat!

Special formula to Cut Pasted Folder names

This can work for you even if you are not familiar with Excel formulas.

In that case, to use the formula unchanged, pasted the folder list into Excel at cell B2. You can start a new Excel sheet so there is nothing else in there.

Copy from this website and Paste my PARTIAL formula below into Excel (I suggest Cell A1).

=TRIM(RIGHT(SUBSTITUTE(B1,

Then continue to write the rest of the formula as

NOTE 1: The formula is shown this way because you need to be sure you get the MS Excel formula quote marks into the formula. A good way to have this is to type it direct into Excel. If you copy and paste, sometimes you get a version of quote marks which will break the formula!

NOTE 2: If you read both sections on how to copy file names into Excel and this one, you will see we can use this very same formula to get only the last part. I love this formula because you can get just the sub-folder name using the exact same formula!

As stated above, to use my formula without any alterations, you will need to have pasted your folder list with paths into cell B1.

If you are familiar with excel formulae, you can paste wherever you need and edit my formula to suit.

That will be easy if you have a basic understanding with Excel formula cell references.

Do not worry, you do not need to know much about formulas or understand this one in particular. Just paste it (preferred) or type it in (less preferred in case you mistype it).

The formula to paste into Cell A1 should look the same as in the following image.

how to copy folder names into excel

This formula is key to cut to the last sub-directory to copy folder names into Excel.

Now you can copy and paste this formula next to every folder path in your list.

For example, you can hover the mouse over the bottom right hand corner of the first cell with the formula in it. When it changes to a little cross, double click and excel will auto-fill the formula all the way down.

Well, that is how to get a list of the folders in a directory in addition to how to extract folder names into Excel.

If you want to see a list of all sub-folders in a directory you will need to do a search (which includes sub-folders) to find the ones you want first, and we covered that above under ‘Selection’.

Translating from another language?

If you are translating this article from another language, please note the formula will not work in an Excel version other than English Excel.

For example, the Trim() function is different in other languages, such as SUPPRESPACE() in French.

There is a handy site which can translate the above excel formula into your language, and it is called the Excel Translator.

Summary

I’ve shown how to copy file names into Excel and how to copy folder names into Excel, including a neat Excel formula that cuts down the entire path to only the filename or lowest level folder.

About The Author

Jeff

Jeff (Surname withheld for family privacy) is an engineer with over 26 years experience. He first learned to program in Fortran 77! See the 'About Us' for more.

Leave A Response

Time limit is exhausted. Please reload CAPTCHA.

* Denotes Required Field