homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque

Webmaster General Forum

Need to Batch Rename 15000+ images help!
image renaming issues

 3:57 pm on Jun 29, 2007 (gmt 0)

Hi there,
I am in the process of moving my store over to yahoo shopping. I am told that in order to have search engine friendly URL's with keywords, the words in the URL would need to be an exact match to the image on the corresponding item page. My images are all currently saved as item number.jpg, some examples of what mine are and what I would need them to be....

546-845.jpg = black-polka-dot-swim-suit.jpg
996-221.jpg = yellow-string-bikini.jpg

Using excel, I have a list of what the images are now named and another column of what I need them to be. Since I have over 15000 images changing the actual file names one at a time would take forever and I am on a deadline. I have found software that will batch rename file extensions, or rename all by dates etc. I have been unable to find anything what will change file names using data from lists and then change the ACTUAL corresponding image names. Is there any program or way that you know of that I can avoid doing this manually? Any help would be GREATLY appreciated



 4:52 pm on Jun 29, 2007 (gmt 0)

Sounds like a job for a custom perl or php script.

Matt Probert

 5:03 pm on Jun 29, 2007 (gmt 0)

I use this. The file names are in an ascii file, each name separated by a tab (\t) and records delimited by a newline.

open(FILE, "tran.lfn");
while (<FILE>)
($old,$new) = split(/\t/, $_);

$result = rename($old, $new);

if ($result == 0)
print "Unable to rename [$old] to [$new]\n";
print "Renamed $old to $new\n";



 5:29 pm on Jun 29, 2007 (gmt 0)

I apologize in advance for not knowing what this means, what type of company or individual should I be looking for the hire to work with this type of code? I have no idea how to interpret your suggestions. I do really appreciate them though!


 12:24 pm on Jun 30, 2007 (gmt 0)

Google for IrfanView - a free and very fast graphic viewer for Windows 9x/ME/NT/2000/XP/2003

It has a batch-rename/resize facility that works at the click of a button... ok, at the click of a few buttons - but no coding is required :)


 7:06 pm on Jun 30, 2007 (gmt 0)

Yeah i first thought of irfanview as well for this but, correct me if i'm wrong, irfanview's batch rename works well on patterns but not one-to-one mappings like mentioned in the OP.

kelleybelly, are you trying to rename the files on your own computer or on the host? If on your own computer, here's what you can do (assuming you got Windows):

- Arrange your Excel worksheet so that it has three columns: the first column has the word "rename" (without the quotes) on all rows, the second column has the original file name, the third has the new file name.

- Save this as a csv file in the directory with your image files.

- Edit the csv file with notepad or your favorite text editor and replace all commas by spaces.

- Change the files's extension to .bat and voila, you have a batch command file to rename all your files.

Before you run the file, make sure you backup everything and also do a small test on a few image files copied to a separate directory. All set? Now run your .bat file and all files should be renamed. You may want to pipe the output to "more" or a log file so you can keep an eye out for errors.

If you want to rename the files on the host, Matt Probert's solution is a good one, it's in PHP. You can do something similar with Perl or FTP scripts. They all start out with exporting your Excel worksheet to a csv file. If you don't feel comfortable doing this yourself, post an ad in craigslist or equivalent explaining what you need to be done. It should be a 1-2 hour job. Stay away from people who tell you it only takes ten minutes, they won't be very cautious and may lose some of your data with carelessness.

Hope this helps.

BTW if you're on Windows, you should get irfanview anyway. It's a great tool for image editing. :)


 9:47 pm on Jun 30, 2007 (gmt 0)

Yeah i first thought of irfanview as well for this but, correct me if i'm wrong, irfanview's batch rename works well on patterns but not one-to-one mappings like mentioned in the OP.

Nope... I was wrong...

Note to self: READ the OP

IrfanView is great, but it doesn't do everything... yet

However, via the Slideshow, you can 'export' file names into a .txt file... quite useful... especially with the following


I have found (and tested) a superb and very small (830kB),fast AND free download (for Windoze) from bulkrenameutility in the UK - google will find it for you

Under the File menu, it has an Import Rename-Pairs option
Create a .txt file with one line per file with file names (with extensions) separated by a pipe (¦) and no spaces, e.g.

I tried it on a folder with 160 images with various file extensions, .g.

It worked perfectly and took less than 0.5 seconds!


And... there is a forum: [bulkrenameutility.co.uk...]


 2:23 am on Jul 1, 2007 (gmt 0)

Perl can do this easily. You need one single perl programmer. It shouldn't be a huge job for them to do this.
Warning: be careful what files you let them have access to. Have backups, because when release a file-renaming program into your directory system, one bug can have disastrous consequences.


 2:47 am on Jul 1, 2007 (gmt 0)

No married Perl programmers?



 6:03 am on Jul 1, 2007 (gmt 0)

^ ^ ^ LOL . . . married perl programmers are painfully familiar with not having access to files (i.e., the home bank account.)

In addition to Matt Probert's script . . . a few notes . . . .

Since you're moving anyway, I would seriously consider adding a function that drops these 15K images into subdirectories, that is, "folders" named 0-9, a-z, and "other." This will speed up maintenance greatly. You may have to alter the way you reference the images but believe me, it's worth it.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved