Renaming Images in Folder from Excel Spreadsheet

jogrady

New Member
Joined
Dec 17, 2004
Messages
23
Hello, hoping someone here can help me.

I have 2500 product images in folder that need to be renamed. I've been giving an Excel spreadsheet that looks like this:

Column A - current file name.
Column B - new file name.

I need a script that will us Column A to find the approrpiate image in the folder and rename it to Column B. Any ideas on how to do this?

Thanks,

John
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It just so happens I use this myself, for anything up to 12,000 images

Code:
For i = 1 To Range("A1").End(xlDown).Row
oldfilename = Cells(i, 1).Value
newfilename = Cells(i, 2).Value
If Not Dir(oldfilename) = "" Then Name oldfilename As newfilename
Next

If you want the workbook PM your email address and I'll send it to you when I get back from work.

EDIT: You will need the full path in column A and B not just the image name, ;)
 
Upvote 0
I should also point out that the code can be used to rename the files to another folder so if in column A you have

C:\Users\Desktop\imagefolder\image.jpg

and you want to move it to newimage folder

C:\Users\Desktop\newimagefolder\image.jpg

Then that will also work
 
Upvote 0
Forgive me, but I'm missing something here. I also have numerous TIFF files (fax files) and they are batched into small directories. I've created a macro that will:
- Make a list of all files in the current directory
- Put the file names into column A (constructing a hyperlink to the file)
- construct formulas in other columns where the name and date are typed in
- the last column displays a new "constructed" file name

The user clicks the link, displays the file and reads the handwritten info from the image and enters info into the spreadsheet.

For example:
FILENAME NAME DATE NEWNAME
233049445.tif | John Smith | 11/8/10 | John_Smith--Nov-08-10.tif

How do I get the VBA to initiate the command

Name 233049445.tif As John_Smith--Nov-08-10.tif?
 
Upvote 0
You would need to put the file path in front of the file name, and in your case you'd want to change the newfilename reference to column B (2) to read column D (4)

So C:\Users\Username\Documents\filename.tif
 
Last edited:
Upvote 0
I can get the correct variables into the VBA, but the question is how do I "Make it so?"

- The user will run a macro to build the worklist.
- The user will spend an unknown amount of time entering data
- When they are done, do I need them to initiate another macro to do the renaming? Or put a mark in a trigger location?
 
Upvote 0
Yes when the user is ready to rename the files they will need to run another macro. You could use another event to trigger the code but it would assume that your users entered data robotically and quite frankly I don't think that's something you'd want to rely on.
 
Upvote 0
Hey,

I'm in an urgent need of an Excel macro that enables me to rename all files in a folder AND put these renamed files in a separate folder.

Can you please mail me this macro of yours on - henanksha@gmail.com

Any help will be much appreciated.

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,796
Members
448,994
Latest member
rohitsomani

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