How to Easily Manage and Rename Image Files from Internet with Excel

As a web designer or a PowerPoint designer, you might be collecting lots of images from the internet for references. However, referring to these collected images during a project is a hectic task as the collected images are either saved with an improper name or with default names. Renaming these images with an appropriate name will help you to save time. In this article, we will show how to do that easily with Excel

Download Now

If you want to start to use the software as soon as possible, then you can:

Download the Software Now

Otherwise, if you want to DIY, you can read the contents below.

Let’s Prepare the GUI

Create two sheets in your Excel workbook. Rename them as “Update” and “Filelist”. “Update” sheet will represent the GUI while sheet “Filelist” will contain the list of images that was selected from the folder. Using shapes, create four buttons. As shown in the image, we need a button to allow the user to select a folder that contains image files. Prev and Next button will help users to navigate to the next or previous image. The button “Change Name” will rename the image file with the new name. For displaying images to the user, we would be using Active X image control. If you are not able to insert Active X controls, then there are higher chances that you might be using a corrupted Excel.Prepare The GUI

Let’s prepare the database

As shown in the image, Sheet “Filelist” will act as the database for our tool. This sheet will hold the root folder and list of all images.Sheet "Filelist" To Act As The Database For Our Tool

Let’s make it functional

Add the script to a new module in your Excel workbook. As explained in this table, attach the macros to the buttons on the sheet “Update”

Button Macro
Select a folder ListImageFiles
Change Name ChangeName
Prev LoadPrevImage
Next LoadNextImage

How does it work?

Macro Description
ListImageFiles This macro allows user to select a folder and loads image names into the sheet “Filelist”
ChangeName This macro renames the selected image file.
LoadPrevImage This macro loads the previous image
LoadNextImage This macro loads the next image

The macro uses the command “Name” to rename image files.

Sub LoadNextImage()
    Sheets("Update").Range("K9").Value = Sheets("Update").Range("K9").Value + 1
    Dim v_row As Integer
    v_row = Sheets("Update").Range("K9").Value
    Sheets("Update").Image1.Picture = LoadPicture(Sheets("Filelist").Range("B1").Value & Sheets("Filelist").Range("B" & v_row).Value)
    Sheets("Update").Range("K7").Value = Sheets("Filelist").Range("B" & v_row).Value
End Sub

Sub LoadPrevImage()
    Sheets("Update").Range("K9").Value = Sheets("Update").Range("K9").Value - 1
    Dim v_row As Integer
    v_row = Sheets("Update").Range("K9").Value
    Sheets("Update").Image1.Picture = LoadPicture(Sheets("Filelist").Range("B1").Value & Sheets("Filelist").Range("B" & v_row).Value)
    Sheets("Update").Range("K7").Value = Sheets("Filelist").Range("B" & v_row).Value
End Sub

Function GetImageDirectory() As String
    Dim v_imagefolder As FileDialog
    Dim v_imageitem As String
    Set v_imagefolder = Application.FileDialog(msoFileDialogFolderPicker)
    With v_imagefolder
        .Title = "Select the Image Folder"
        .AllowMultiSelect = False
        .InitialFileName = Application.DefaultFilePath
        If .Show <> -1 Then GoTo NextCode
        v_imageitem = .SelectedItems(1)
    End With
    NextCode:
    If Right(v_imageitem, 1) <> "\" Then
        v_imageitem = v_imageitem & "\"
    End If
    GetImageDirectory = v_imageitem
    Set v_imagefolder = Nothing
End Function

Sub ListImageFiles()
    Dim v_fldrpath As String, v_pth As String, v_filecount As Integer
    v_fldrpath = GetImageDirectory
    Sheets("Filelist").Range("B1").Value = v_fldrpath
    v_pth = v_fldrpath
    Filename = Dir(v_pth)
    Do While Filename <> ""
        v_filecount = v_filecount + 1
        Sheets("Filelist").Range("A" & v_filecount + 2).Value = v_filecount
        Sheets("Filelist").Range("B" & v_filecount + 2).Value = Filename
        Filename = Dir()
    Loop
    Sheets("Update").Image1.Picture = LoadPicture(Sheets("Filelist").Range("B1").Value & Sheets("Filelist").Range("B3").Value)
    Sheets("Update").Range("K9").Value = 3
    Dim v_row As Integer
    v_row = Sheets("Update").Range("K9").Value
    Sheets("Update").Image1.Picture = LoadPicture(Sheets("Filelist").Range("B1").Value & Sheets("Filelist").Range("B" & v_row).Value)
    Sheets("Update").Range("K7").Value = Sheets("Filelist").Range("B" & v_row).Value
End Sub

Sub ChangeName()
    Dim oldname As String, newname As String
    oldname = Sheets("Filelist").Range("B1").Value & Sheets("Update").Range("K7").Value
    newname = Sheets("Filelist").Range("B1").Value & Sheets("Update").Range("K11").Value
    Name oldname As newname
    Dim v_row As Integer
    v_row = Sheets("Update").Range("K9").Value
    Sheets("Filelist").Range("B" & v_row).Value = Sheets("Update").Range("K11").Value
    Call LoadNextImage
End Sub

Author Introduction:

Nick Vipond is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including Word repair and outlook recovery software products. For more information visit www.datanumen.com

One response to “How to Easily Manage and Rename Image Files from Internet with Excel”