Using excel list to rename Image files

pixure

New Member
Joined
Apr 4, 2007
Messages
1
I have an excel spread sheet with two columns. The first is a long list of current file names of a large number of image files in a single folder. The second column represents the new name we would like each image file to have. We are Mac OS. I am not trained in Visual Basic, but I am trying to create a Macro to do the following. I need Excel to start with cell A1 and locate that named image file in a specific folder on my hard drive. I then need excel to rename the file with the name with cell B1 and then proceed to cell A2 and repeat.

Any guidance appreciated,

Kent
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This would surely work in a pc. I cannot tell about Mac but give it a try.
Code:
Dim FSO, objFolder, Folder, LR As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\mypics\") 'here set your directory of photos
LR = [a65536].End(xlUp).Row
For Each file In Folder.Files
    For i = 1 To LR
        ' assume that the pics format is jpg. For else or if names at columns A & B _
        include the filename extension, change code accordingly
        If file.Name Like Cells(i, 1) & ".JPG" Then file.Name = Cells(i, 2) & ".JPG"
    Next i
Next file
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top