Skip to main content

How to quickly list the picture names/file names of a folder to Excel cells?

In this tutorial, I will provide some tricks on quickly listing all picture names or file names of a specific folder in an Excel sheet as the screenshot shown.

QUICK NAVIGATION

List picture names of a folder in Excel with VBA
List picture names or specific format file names of a folder in Excel with Filename List
Download sample file

doc list picture name 1

List picture names of a folder in Excel with VBA

In Excel, there is no built-in function that can automatically list all picture names of a folder you choose in a cell of a sheet, but here I have a VBA code which can help you quickly solve this job.

1. In Excel, then press + keys to open Microsoft Visual Basic for Applications window.

2. In popping window, click Insert > Module to create a new Module script.

3. Copy below code and paste them to the new Module script window.

Sub PictureNametoExcel()
'UpdatebyExtendoffice 
    Dim I As Long
    Dim xRg As Range
    Dim xAddress As String
    Dim xFileName As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Select a cell to place name list:", "Kutools For Excel", xAddress, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Set xRg = xRg(1)
    xRg.Value = "Picture Name"
    With xRg.Font
    .Name = "Arial"
    .FontStyle = "Bold"
    .Size = 10
    End With
    xRg.EntireColumn.AutoFit
    Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
    I = 1
    If xFileDlg.Show = -1 Then
        xFileDlgItem = xFileDlg.SelectedItems.Item(1)
        xFileName = Dir(xFileDlgItem & "\")
        Do While xFileName <> ""
            If InStr(1, xFileName, ".jpg") + InStr(1, xFileName, ".png") + InStr(1, xFileName, ".img") + InStr(1, xFileName, ".ioc") + InStr(1, xFileName, ".bmp") > 0 Then
                xRg.Offset(I).Value = xFileDlgItem & "\" & xFileName
                I = I + 1
            End If
            xFileName = Dir
        Loop
    End If
    Application.ScreenUpdating = True
End Sub

4. Press F5 key, then a dialog pops out for you to select a cell to place the picture names.
doc list picture name 1

5. Click OK to continue selecting the folder you want to list the picture names in Browse dialog.
doc list picture name 3

6. Click OK, now all picture names in the selected folder have been list in Excel.
doc list picture name 13

Note: In the VBA code, you can jpg/png/… in the code string If InStr(1, xFileName, ".jpg") + InStr(1, xFileName, ".png") + InStr(1, xFileName, ".img") + InStr(1, xFileName, ".ioc") + InStr(1, xFileName, ".bmp") > 0 Then to the file extension you need, for example, if you want to list file names of the file in doc format, only change the code string to If InStr(1, xFileName, ".doc") > 0 Then.

If you usually need to list one or all formats’ file names of a folder in Excel cell in your daily work, the code is complex and no easy to handle, but, with below way, you can quickly solve this job.


ot move

Do You Want To Have A Pay Raise and Much Time To Accompany With Family?

Office Tab Enhances Your Efficiency By 50% In Microsoft Office Working Right Now

Unbelievable, working at two or more documents is easier and faster than working at one.

Compareed with well-known browsers, the tabbed tool in Office Tab is more powerful and more efficient.

Reduce hundreds of mouse-clicks and keyboard typing every day for you, say goodbye to the mouse hand now.

If you usually work at multiple documents, Office Tab will be a great time-saver for you.

30-day free trial, no credit card required.

Read MoreFree Download Now


List picture names or specific format file names of a folder in Excel with Filename List

Here is a utility – Filename List in Kutools for Excel, which can

>> list all file names in all file formats of a folder in a new sheet;

>> list the file names in one or several file formats you specify to Excel;

>> list file names including subfolders and hidden files and folders to Excel.

Say Goodbye To Mouse Hand and Cervical Spondylosis Now

300 advanced tools of Kutools for Excel solve 80% Excel tasks in seconds, pull you out of the thousands of mouse-clicks.

Easily deal with 1500 working scenarios, no need to waste time for searching solutions, have much time to enjoy your life.

Improve 80% productivity for 110000+ highly effective people every day, of course including you.

No longer to be tormented by painful formulas and VBA, give your brain a rest and joyful working mood.

30-day free trial with full features, 30-day money back without reasons.

A Better Body Creates A Better Life.

After free installing Kutools for Excel, please do as below:

1. Enable the workbook you want to list the file names, then click Kutools Plus > Import/Export > Filename List.
doc list picture name 4

2. In the Filename List dialog, firstly, click  doc list picture name 5 to select a folder that you want to list its file names, then you can check the checkboxes of Include files in subdirectories and Include hidden files and folders as you need.
doc list picture name 6

3. Then select the file format you want to list the names in Files type section.

Check All files option, it will list all the file names in all the file formats in the selected folder
doc list picture name 7
Check Common option, and select the specific file format you want to list the file names from the drop down list, then it will list all the file names of the file format you choose in the drop down list
doc list picture name 8
Check Specify option, then type the file extensions (using comma to separate them) you want to list the file names in the textbox, then it will only list the file names with the inputting file extensions in Excel
doc list picture name 9

4. Choose the size unit as you need from the drop down list in File size unit section, if you want to create a link to the file names, check Create hyperlinks option.

doc list picture name 10 doc list picture name 11

5. Click Ok, a new sheet will be created to list the file names and some file information.
doc list picture name 12

Tip: if you want to list all sheet names in Excel, you can apply Kutools for Excel’ Create List of Sheet Names utility, it will create a new sheet to list all linkable sheet names.
create sheet name list

Kutools for Excel:+ useful handy tools, simplifying the complicated tasks in Excel into a few clicks.


Download Sample File

sample


How To Make You Stand Out From Crowd, Easily Work And Leisurely Enjoy Life?

Kutools for Excel will averagely improve your 80% efficiency every day, make you have much time to accompany with family and have fun in life.

300 advanced tools solve 80% Excel problems, you no longer struggle to search solutions, more easily complete work.

Easily handle 1500 Excel scenarios, save at least 1 hour for you every day.

Become an Excel expert in 5 minutes, gain peoples’ recognition and opportunity for promotion.

One-click utilities handle batch processing, let you avoid thousands of mouse-clicks, say good-bye to mouse hand.

Get rid of rote memorizing formulas and complex VBA, give a rest to your brain.

110000+ high efficiency officers and 300+ world renowned companies’ choice.

Only take $39 but much worth than $4000 training of other people

30 days free trial without any limitation, full money back in 30-day without any reasons.


Recommended Productivity Tools

Office Tab - Tabbed Browsing, Editing, Managing Of Documents In Microsoft Office 2019 - 2003 And Office 365


office tab

A Professional Add-in for Accelerating Excel 2019-2007, shrink hours tasks to seconds

This add-in includes dozens of professional groups, with 300+ options will automate most of your daily tasks in Excel, and increase your productivity at least by 50%. Such as groups of one-click optons and batch conversions.
Now it's your chance to speed up yourself with Kutools for Excel!


Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hey! This is super quick and thanks
This comment was minimized by the moderator on the site
Thanks so much for this!
This comment was minimized by the moderator on the site
In Libreoffice Calc I use the function of importing a list of files into the rows / columns of a Calc table, via Macro and based on certain criteria - I have created a button on the toolbar for this particular macro, and after pressing it, I select a folder, and the list of images is immediately inserted into a new document. How to make it as easy as possible in Excel? I have a lot of folders that contain 1 or more images and I need to:
> If the folder contains 1 image, I need it to be on a new line in Excel.
> If the folder contains more images, the first being on a new line and the second either:
- next to the first in the same row (in one column), separated by the character | (example: photo 1.jpeg | photo 2.jpeg)
- or to have their names in the columns (even without the | character) (the first option would be better, but the second is enough as well)

These are the product images whose names I need for import into Woocommerce - via a csv file.
This comment was minimized by the moderator on the site
Amazing! Thank you for sharing!
This comment was minimized by the moderator on the site
Hi,
As per the above code I am getting the the images name in an incrementing order, however the path where the images are being placed are in numeric incrementation.

Kindly suggest how I can keep the same formatting.
This comment was minimized by the moderator on the site
How to export an image with specific file name in excel.
This comment was minimized by the moderator on the site
I WAS HAVING THE SAME PROBLEM TANNER, IN THE SCRIPT WHERE IT HAS THE DIFFERENT FILE EXTENSIONS ITS GOING TO GRAB,YOU HAVE TO CAPITALIZE THE FILE EXTENSION ITS LOOKING FOR, FOR EXAMPLE, YOU SAID YOUR FILES ARE ".png", WELL IF YOU CAPITALIZE IT I.E ".PNG" IT MAY WORK.
This comment was minimized by the moderator on the site
Now it works for me. Thanks!!!
This comment was minimized by the moderator on the site
Is it possible that there is something wrong with the code? The file explorer is showing my folder full of images (.png) as empty.
This comment was minimized by the moderator on the site
Is it possible something is wrong with the code? Because it shows folders full of images (.png) as empty when it pulls up the box to select the photos.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations