+ Reply to Thread
Results 1 to 5 of 5

renaming images in a folder using the data from an excel sheet

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    hyd
    MS-Off Ver
    Excel 2003
    Posts
    22

    renaming images in a folder using the data from an excel sheet

    I have an excel file which consists of old name and new name in two different columns. I have 500 photos in a folder. I want to rename the photos with the new names when there is a match with the old name(same as that of image name) in the excel.
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: renaming images in a folder using the data from an excel sheet

    Hi, dvnr_76,

    there´s a little bit more that you need to consider than just giving up the name of the files: you could give some information about the folder or the extension of the images. Please adjust the constants to suit:

    Please Login or Register  to view this content.
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    hyd
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: renaming images in a folder using the data from an excel sheet

    Dear ciao thanks a lot.. but i am unable to update... i tried the following

    Sub EF973849()

    Dim lngCounter As Long

    Const cstrFOLDER As String = "C:\Users\nagaraju\Desktop\I IT Photos"
    Const cstrSHEET As String = "Sheet1"
    Const cstrEXTENS As String = ".JPG"

    With Sheets(cstrSHEET)
    For lngCounter = 2 To .Range("A" & Rows.Count).End(xlUp).Row
    If Len(Dir(cstrFOLDER & .Cells(lngCounter, "A").Value & cstrEXTENS)) > 0 Then
    Name (cstrFOLDER & .Cells(lngCounter, "A").Value & cstrEXTENS) As (cstrFOLDER & .Cells(lngCounter, "B").Value & cstrEXTENS)
    End If
    Next lngCounter
    End With
    End Sub

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: renaming images in a folder using the data from an excel sheet

    Hi, dvnr_76,

    you would need to rap your code with code-tags according to Forum Rule #3.

    Your code
    Please Login or Register  to view this content.
    is missing the last backslash as shown in my example.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    hyd
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: renaming images in a folder using the data from an excel sheet

    Wow u r brilliant... it helped me lot... thnak you very much..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 10-08-2013, 02:46 PM
  2. Listing/Renaming Files in a folder from excel
    By Kelshaer in forum Excel Tips
    Replies: 4
    Last Post: 01-23-2013, 11:04 AM
  3. Merging excel files + renaming them with folder name + restructuring them
    By BohkAl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2011, 07:47 AM
  4. Excel files replicating and renaming in a folder
    By hpum in forum Excel General
    Replies: 0
    Last Post: 07-21-2007, 09:23 AM
  5. Replies: 1
    Last Post: 06-23-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1