Importing file names to excel

In this short post, I’m going to show you how to easily copy all filenames in a Window folder to Microsoft Excel.

First a caveat, the main limitation of the method I’m going to show you, is that you cannot copy filenames in subfolders. If you want to learn how to how to copy filenames in subfolders, check out the how to easily copy all filenames in a folder to Excel using CMD post.

Let’s jump right into it.

Step 1: Open Excel

Open up excel and then navigate to the folder that contains the files.

Step 1: Open Excel

Step 2: Navigate to Folder and Select All the Files

Navigate to the folder that contains the files.  In the folder that contains the files, select all the files in the folder. You can use the shortcut keys, Ctrl + a.

Step 2: Navigate to Folder and Select All the Files

Step 3: Hold Shift Key and Right Click

Now, holding the Shift key, hover over your selection and right click. Don’t let go of the Shift key before you right click.

Step 3: Hold Shift Key and Right Click

Step 4: Click Copy as Path                

In the window that pops up, click copy as path. This copies the file path of all the files to the Clipboard.

Step 4: Click Copy as Path

Step 5: Paste Filepaths in Excel

Navigate to Excel, I’m using ALT and Tab key, and paste the file paths.

Step 5: Paste Filepaths in Excel

Step 6: Use Replace Function in Excel

We are going to remove the folder path using replace function in excel and we’ll have the filenames.

So double click on one of the cells, select and copy the folder path. Click on Find and Select, scroll down to replace. Click on replace and paste the folderpath. Then click on replace all.

Step 6: Use Replace Function in Excel

Close the Find and Select dialog. Save your excel document and you have successfully copied all the file names in a folder into an excel document.

That’s it for this post, if you want to learn how to also copy the filenames into text check out this post on how to copy file names in windows explorer to text.

And here’s a short how-to video:

Import or export text (.txt or .csv) files

There are two ways to import data from a text file with Excel: you can open it in Excel, or you can import it as an external data range. To export data from Excel to a text file, use the Save As command and change the file type from the drop-down menu.

There are two commonly used text file formats:

  • Delimited text files (.txt), in which the TAB character (ASCII character code 009) typically separates each field of text.

  • Comma separated values text files (.csv), in which the comma character (,) typically separates each field of text.

You can change the separator character that is used in both delimited and .csv text files. This may be necessary to make sure that the import or export operation works the way that you want it to.

Note: You can import or export up to 1,048,576 rows and 16,384 columns.

Import a text file by opening it in Excel

You can open a text file that you created in another program as an Excel workbook by using the Open command. Opening a text file in Excel does not change the format of the file — you can see this in the Excel title bar, where the name of the file retains the text file name extension (for example, .txt or .csv).

  1. Go to File > Open and browse to the location that contains the text file.

  2. Select Text Files in the file type dropdown list in the Open dialog box.

  3. Locate and double-click the text file that you want to open.

    • If the file is a text file (.txt), Excel starts the Import Text Wizard. When you are done with the steps, click Finish to complete the import operation. See Text Import Wizard for more information about delimiters and advanced options.

    • If the file is a .csv file, Excel automatically opens the text file and displays the data in a new workbook.

      Note: When Excel opens a .csv file, it uses the current default data format settings to interpret how to import each column of data. If you want more flexibility in converting columns to different data formats, you can use the Import Text Wizard. For example, the format of a data column in the .csv file may be MDY, but Excel’s default data format is YMD, or you want to convert a column of numbers that contains leading zeros to text so you can preserve the leading zeros. To force Excel to run the Import Text Wizard, you can change the file name extension from .csv to .txt before you open it, or you can import a text file by connecting to it (for more information, see the following section).

Import a text file by connecting to it (Power Query)

You can import data from a text file into an existing worksheet.

  1. On the Data tab, in the Get & Transform Data group, click From Text/CSV.

  2. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

  3. In the preview dialog box, you have several options:

    • Select Load if you want to load the data directly to a new worksheet.

    • Alternatively, select Load to if you want to load the data to a table, PivotTable/PivotChart, an existing/new Excel worksheet, or simply create a connection. You also have the choice of adding your data to the Data Model.

    • Select Transform Data if you want to load the data to Power Query, and edit it before bringing it to Excel.

If Excel doesn’t convert a particular column of data to the format that you want, then you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File > Save As.

  2. Click Browse.

  3. In the Save As dialog box, under Save as type box, choose the text file format for the worksheet; for example, click Text (Tab delimited) or CSV (Comma delimited).

    Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

    You may also see an alert below the ribbon that some features might be lost if you save the workbook in a CSV format.

For more information about saving files in other formats, see Save a workbook in another file format.

Import a text file by connecting to it

You can import data from a text file into an existing worksheet.

  1. Click the cell where you want to put the data from the text file.

  2. On the Data tab, in the Get External Data group, click From Text.

  3. In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

    Follow the instructions in the Text Import Wizard. Click Help button image on any page of the Text Import Wizard for more information about using the wizard. When you are done with the steps in the wizard, click Finish to complete the import operation.

  4. In the Import Data dialog box, do the following:

    1. Under Where do you want to put the data?, do one of the following:

      • To return the data to the location that you selected, click Existing worksheet.

      • To return the data to the upper-left corner of a new worksheet, click New worksheet.

    2. Optionally, click Properties to set refresh, formatting, and layout options for the imported data.

    3. Click OK.

      Excel puts the external data range in the location that you specify.

If Excel does not convert a column of data to the format that you want, you can convert the data after you import it. For more information, see Convert numbers stored as text to numbers and Convert dates stored as text to dates.

Export data to a text file by saving it

You can convert an Excel worksheet to a text file by using the Save As command.

  1. Go to File > Save As.

  2. The Save As dialog box appears.

  3. In the Save as type box, choose the text file format for the worksheet.

    • For example, click Text (Tab delimited) or CSV (Comma delimited).

    • Note: The different formats support different feature sets. For more information about the feature sets that are supported by the different text file formats, see File formats that are supported in Excel.

  4. Browse to the location where you want to save the new text file, and then click Save.

  5. A dialog box appears, reminding you that only the current worksheet will be saved to the new file. If you are certain that the current worksheet is the one that you want to save as a text file, click OK. You can save other worksheets as separate text files by repeating this procedure for each worksheet.

  6. A second dialog box appears, reminding you that your worksheet may contain features that are not supported by text file formats. If you are interested only in saving the worksheet data into the new text file, click Yes. If you are unsure and would like to know more about which Excel features are not supported by text file formats, click Help for more information.

For more information about saving files in other formats, see Save a workbook in another file format.

The way you change the delimiter when importing is different depending on how you import the text.

  • If you use Get & Transform Data > From Text/CSV, after you choose the text file and click Import, choose a character to use from the list under Delimiter. You can see the effect of your new choice immediately in the data preview, so you can be sure you make the choice you want before you proceed.

  • If you use the Text Import Wizard to import a text file, you can change the delimiter that is used for the import operation in Step 2 of the Text Import Wizard. In this step, you can also change the way that consecutive delimiters, such as consecutive quotation marks, are handled.

    See Text Import Wizard for more information about delimiters and advanced options.

If you want to use a semi-colon as the default list separator when you Save As .csv, but need to limit the change to Excel, consider changing the default decimal separator to a comma — this forces Excel to use a semi-colon for the list separator. Obviously, this will also change the way decimal numbers are displayed, so also consider changing the Thousands separator to limit any confusion.

  1. Clear Excel Options > Advanced > Editing options > Use system separators.

  2. Set Decimal separator to , (a comma).

  3. Set Thousands separator to . (a period).

When you save a workbook as a .csv file, the default list separator (delimiter) is a comma. You can change this to another separator character using Windows Region settings. 

Caution: Changing the Windows setting will cause a global change on your computer, affecting all applications. To only change the delimiter for Excel, see Change the default list separator for saving files as text (.csv) in Excel.

  1. In Microsoft Windows 10, right-click the Start button, and then click Settings.

  2. Click Time & Language, and then click Region in the left panel.

  3. In the main panel, under Regional settings, click Additional date, time, and regional settings.

  4. Under Region, click Change date, time, or number formats.

  5. In the Region dialog, on the Format tab, click Additional settings.

  6. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.

  7. Click OK twice.

  1. In Microsoft Windows, click the Start button, and then click Control Panel.

  2. Under Clock, Language, and Region, click Change date, time, or number formats.

  3. In the Region dialog, on the Format tab, click Additional settings.

  4. In the Customize Format dialog, on the Numbers tab, type a character to use as the new separator in the List separator box.

  5. Click OK twice.

Note:  After you change the list separator character for your computer, all programs use the new character as a list separator. You can change the character back to the default character by following the same procedure.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See Also

Import data from external data sources (Power Query)

Need more help?

I’m trying to implement a command button in my excel sheet that will prompt the user to select the files he wants to load before loading the selected files into the specified cells. So far I have tried using the following code but to no avail. I have been getting a type 13 error

Sub check11()
Dim FileName() As Variant
Dim f As String
Dim i As Variant
Dim j As Variant
Dim rng As Variant

rng = ActiveCell.Address
f = Application.GetOpenFilename("TXT File (*.txt), *.txt")
For i = 0 To 1
    FileName(f) = j
    Range(rng).Value = j
    ActiveCell.Offset(1, 0).Select
Next i

End Sub

Miller86's user avatar

Miller86

4047 silver badges17 bronze badges

asked Dec 15, 2015 at 9:46

UTVBA's user avatar

2

GetOpenFileName doesn’t work in the way you have coded it. You can’t select multiple files (as far as I’m aware) so the loop you run is redundant. The function will return either False if the user hits Cancel or the name of the file as a string. You ought to test for the Cancel case within your code.

I can’t see the purpose of your loop or why you’re selecting the offset cell. I think it might be a development error so I’ve just disregarded it.

Below is some code that shows you how the GetOpenFileName function could work in your context:

Sub check11()
    Const TARGET_COL As String = "A" 'adjust letter for your column
    Dim ws As Worksheet
    Dim selectedFile As Variant
    Dim cell As Range

    'Find the next blank cell in target column
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Set cell = ws.Cells(ws.Rows.Count, TARGET_COL).End(xlUp).Offset(1)

    'Open the file dialog window
    selectedFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")

    'Check if user hit cancel
    If selectedFile = False Then Exit Sub

    'Write the file name
    cell.Value = selectedFile

End Sub

answered Dec 15, 2015 at 10:40

Ambie's user avatar

AmbieAmbie

4,7122 gold badges14 silver badges26 bronze badges

You have inccorect acces to Application.GetOpenFilename first of all you need to set MultiSelect to true so you will be able to select multiple files. Then this function will return array which you can loop. In loop i spliting filepath by «» and with knowledge that filename is always last, i just write filename into cell.

Sub check11()

Dim filePath() As Variant
Dim i As Long

filePath = Application.GetOpenFilename("TXT File (*.txt), *.txt", MultiSelect:=True)
For i = 1 To UBound(filePath)

    Sheets("Sheet2").Cells(1 + i, 1).Value = Split(filePath(i), "")(UBound(Split(filePath(i), "")))
Next i

End Sub

answered Dec 15, 2015 at 10:49

Luboš Suk's user avatar

Luboš SukLuboš Suk

1,51615 silver badges38 bronze badges

3

How do I copy a list of file names into Excel?

If this is the same question popping in your mind, then you are at the right place.

Also Read: How to Enable Text to Speech On Windows 10.

From the last 2-3 years, I have started backing up my computer files to some external hard drives. To prevent data loss.

And till now I have filled 4-5 hard drives of data.

But it’s really difficult to remember which files are present in which hard drive.

So I started exporting all files names to excel files & keep a record of it.

But it was hell time-consuming. And then I got to know about this trick method of copying filenames from folder in windows explorer.

Let see How it works…

This method of creating a list of the contents of a folder as text has helped me a lot in saving my time. Whether they are too long, short or one word it works with all.

Moreover, you can also create a directory of files present in a folder.

So let’s get started.

1. Open Windows Explorer

Open Windows Explorer and navigate to your favorite folder for which you want to create a list of filenames as text.

Open Windows Explorer

2. Copy File Names as Text from folder

Now select only those files for which you want to copy file names into excel from the folder.

Copy File Names as Text from folder

Now, Press Shift key + Right Click on it. And then select Copy as path Option.

And you have successfully copied files as text and also its location with the file extension.

3. Export Filenames to Excel

Now it turns to export filenames to excel file in windows 10. So, Open your Excel sheet and Press Ctrl+V to paste it properly.

Export Filenames to Excel

And you can also copy filenames to Notepad as text using this technique.

Some FAQs

How do I copy file names into Excel Windows 10?

To copy file names into excel in Windows 10, go to the desired folder, select all files, hold the Shift key & right-click and then click on the Copy as Path option.

How do I copy a list of filenames into Excel?

If you want to copy a list of filenames into excel, just select all the files, hold shift + right-click & then choose Copy as Path option.

How can I copy a list of file names as text?

To copy the list of file names as text, Select the full list > Hold Shift-key + Right-click > Copy as Path and then paste it into a notepad file as text.

How do I copy the names of all files in a folder Windows 10?

Copying the names of all files in a folder using Windows 10 is pretty easy, just press Ctrl+A to select the files, right-click on them while holding the Shift key, and then select the “Copy as Path” from the options.

That’s it for now…

Conclusion

So that’s how you can easily get a list of all files in a folder and subfolders into excel. And you can also follow the same method for Windows 7/8.

Check out the next post on how to copy filenames to excel using cmd.

Feel free to share your thoughts and also tell us if you know any better way to Export or Copy File Names Into Excel From Folder in Windows 10.

If you liked this post, Don’t forget to share this post.

using macros to import files names

The task Import file names to Excel can be born from the idea of ​​transcribing the number of elements forming part of a folder. Although for some people no sense to import this information into Excel. The truth is sometimes necessary in the workplace.

A clear example of this is a business administration and accounting. Whose computer contains a folder full of files, where each part of the financial monitoring that is done each client.

If for some reason the company requests a backup of all clients who offers service with this method you can create a list automatically .

Import file names to Excel via macros

Apply the task of importing files can provide any people spend hours in front of a computer, transcribing the name of each file. The Office package has a handy tool called «Macros». These macros can be developed by yourself, you just need discover how easy it is to create macros.

You may also be interested in:

These macros are responsible for execute a sequence of actions & nbsp; (Also known as algorithm) within the program. To prevent the user to perform certain manual procedures and can automate your work more efficiently.

Creating and defining macros to import file names to Excel

A the same as any other language, is a series of commands that are recognized within the system to perform a specific task, determining the action to be performed .

macros to import file names to Excel

To create it, you click on the button «Macros» which can locate the Excel toolbar. After that you can start a new module and begin to develop it.

Both the beginning and the end of the action is determined as a subroutine. Which can take any name you want, but remember that should be opened with « Under «.

Set variables within the code

Variables are nothing more than names that characterize a given, action or value specific. You can call and variables define the way you want better. This being the first step of importing the file names to Excel, so we will call for explanation as «Folder», «File» and» count».

The first will store the information the path where the folder in question. The second file name and the last sequence in each cell occupying names, to form a list. Within the code, this will be achieved by appointing the first two values ​​» As String «, and the third as « Integer «.

Define the folder path

Because the functions of the first variable, it is necessary to solicit users to the address where the folder is stored. This is achieved through» inputBox» .

Define the folder path

This command also establishes the validation of information, so that the acting system specifically depending on the situation. Terminate the procedure if the folder is empty or validate the text string to be formed with the names

Running the counting function

This variable will take care of the reading folder via «Dir» , automatically translating the names of each of the files. Which will continue to advance within the row until the whole content.

To finish importing the file names to Excel, the spreadsheet is automatically transformed into a kind of row. Whose cells make up a list with the names of the contents of the folder.

Currently, the agility to create this style serves a guaranteed content in any field, even to generate a simple database even importing data from Excel to a database OpenOffice about what stored in a computer in order to have a record.

Also, efficiency and functionality allows multiple users save significant time transcription , and to prevent data loss is always advisable to learn how to activate the autoguadado our poyecto.

You may also be interested in:

Copying files in excel is an important skill that you need as a student or a business person. It is necessary for an individual in this modern technological era to learn copying file name in excel. It is one of the most useful skill in the world.

The copy file name option in Excel is a useful way to display chunk of files in excel or make changes to the name of a file. If you want to copy large number of file names into excel, it will be a hectic and tedious task if you type them manually. In this article we will show you how copy file names in excel in easy and simple way. There are different methods to do it. Let us take you through to each one by one.

Tips that are provided in this article are compatible with versions 2010/2013/2016.

USING CTRL+C AND CTRL+V TO COPY FILE NAMES IN EXCEL

If you want to copy the name of a file in Excel, use CTRL+C and CTRL+V. The keyboard shortcut is Ctrl+c, followed by Ctrl+v on your PC or Command+c followed by Command+v on Mac.

This works well if you want to paste the copied name into another column or cell of your workbook. For example, if you want to copy a filename from one sheet and paste it into another sheet, then use ctrl-c followed by ctrl-v.

1. Open Excel as well as file explorer Open File Explorer

2. Select the file you want to copy.

3. Press CTRL+C

4. Paste the file by using CTRL+V on Excel sheet.

USING COPY AS PATH TO COPY FILE NAMES IN EXCEL

Copy as Path is used to create shortcuts on the desktop and in the Start menu. It is very useful when you want to create shortcuts for files or folders that are located at different locations on your computer.. You can also use this to copy file names into excel.

To copy a file name in Excel, you can use the following steps:

1. Open Excel. 

2. Navigate to the folder and select the required files.

3. Right click the mouse, a window will pop up. In this window, select copy as path. This copy the path of files to clipboard.

4. Navigate to excel, press the ALT + TAB key, and paste the files.

And that’s it , you have copied file names into the excel

Copying File name in Excel using Import data

1. Click on Data > Import Data > From File > Select data source.

2. Enter the main folder of your files and select the files you want to import

3. Select open and your file name is copied into excel.

That’s how you import files into excel by using in built tools

Did you learn about how to copy file names in excel using different methods. You can follow WPS academy to learn more features of Word document, Excel Spread sheets, and power point slides.

You can also download WPS office to edit the word documents , Excel Spread sheets, and PowerPoint free of cost. Download Now! And get an enjoyable working space.

Понравилась статья? Поделить с друзьями:
  • Importing excel into sql
  • Importing excel in stata
  • Importing excel data to access
  • Importing data into к from excel
  • Importing data from excel to sql server