Software/Method to Batch Rename 3000+ JPGs?

kanehood

New member
Oct 23, 2009
88
5
0
So, I've got a little over 3000 JPGs, and they're currently formatted in Amazon gibberish style:
aas56dAW3_ZsGbasd234.jpg
g5s7DjfgGaGZhse0LgS34s.jpg
etc.
I'd like to rename them all, from gibberish to:
product-keyword-00001.jpg
product-keyword-00002.jpg
etc.
Further more, I need a way to keep track of the change, like a log, so I can change the file name in my CSV file.

If I can find a way to batch rename the files in alphabetical order, I could sort my CSV in Excel by the file name alphabetically, and I think I'd be able to replace the file names in order. I'd have to be careful and keep backups but I think it could do the job well. But, I'd need a way to rename the files in order first for this to work.

Any ideas? I did a forum search and couldn't find anything on this...
 


Also, I hope this is the right board for this question, it seemed to fit better here than the Content board...
 
A little confused. How do you know that aas56dAW3_ZsGbasd234.jpg = product-keyword.jpg (assuming these are a bunch of different products)?
 
A little confused. How do you know that aas56dAW3_ZsGbasd234.jpg = product-keyword.jpg (assuming these are a bunch of different products)?

All of the products are related as far as the site's target keyword is concerned. For example, if it was yet another golf club site just for pitching wedges, they would all be renamed:

pitching-wedge-00001.jpg
pitching-wedge-00002.jpg

So, I'm looking for something that could rename the 3000 images like this:

pitching-wedge-00001.jpg
to
pitching-wedge-03000.jpg
 
Highlight all, right click, rename picture = WINRAR

But seriously, like nvan said, how the fuck are you going to know what to name them if it's in all gibberish? Unless you just want to rename them all a broad term in which case my highlight all option would actually work perfectly.


That sounds like it could be my trick. A visit to the WinRAR pages tells me this:

Source: WinRAR download and support. WinRAR is a powerful Windows tool to compress and decompress zip, rar and many other formats: Whats New
"8. New "Rename automatically" option in the extraction dialog and command line -or switch to rename extracted files automatically if file with the same name already exists. You can also enable the auto-renaming mode directly from the overwrite confirmation prompt with "Rename All" button.
Renamed files will get names like 'filename(N).txt', where 'filename.txt' is the original file name and 'N' is a number. "

That sounds like it could be my solution, will have to look at the options closer, though. Thanks a lot for the help, +rep given.
 
Na, winrar is just a meme(me being an idiot). You don't need winrar.
Just right click inside the picture folder and select "select all". Then right click on one of the highlighted pictures and right click on it and choose to rename the file. Since you have all the pictures highlighted it will rename all of them. So if you rename that picture to "product.jpg" it will make the rest names product.001.jpg product002,jpg etc etc


That sounds like it could be my trick. A visit to the WinRAR pages tells me this:

Source: WinRAR download and support. WinRAR is a powerful Windows tool to compress and decompress zip, rar and many other formats: Whats New
"8. New "Rename automatically" option in the extraction dialog and command line -or switch to rename extracted files automatically if file with the same name already exists. You can also enable the auto-renaming mode directly from the overwrite confirmation prompt with "Rename All" button.
Renamed files will get names like 'filename(N).txt', where 'filename.txt' is the original file name and 'N' is a number. "

That sounds like it could be my solution, will have to look at the options closer, though. Thanks a lot for the help, +rep given.
 
EDZT2.png

highlight all the files in the folder you wanna rename, rightclick on one of the files, rename = all files will be renamed.
 
I would normally be a dick and say Google "file renamer" but I'll help ya out this time :)

These are both fantastic tools...

http://www.bulkrenameutility.co.uk
PFrank File Renamer

I did, about 4 searches actually, but I'm picky about even slightly sketchy software and didn't see anything that looked like a good solution. Thanks for the links, though, I'll look into those as well. I'm thinking the Windows UI Rename function might work fine for me.
 
{screenshot here}
highlight all the files in the folder you wanna rename, rightclick on one of the files, rename = all files will be renamed.

Didn't realize you could do that. I've had Windows 7 for two months now and was using Vista and XP before that and never knew about this, anyone know at what point this functionality showed up?

+reps to all, thanks again for the assistance.
 
I did, about 4 searches actually, but I'm picky about even slightly sketchy software and didn't see anything that looked like a good solution. Thanks for the links, though, I'll look into those as well. I'm thinking the Windows UI Rename function might work fine for me.

I assure you that, though the sites might not look so sweet, both are fully legit and work great. They're both quite powerful.
 
You mentioned wanting to record the old and new names for each file. I was bored so I wrote a script to do it in PHP actually. Just put it somewhere with a directory called "images" and it'll do what you want inside that folder plus log the old and new names. I understand that you are on Windows but hey I'm trying to learn PHP on Linux right now so... :D (This taught me about printf() and sprintf(), yay!)

Code:
<?php

$folder = 'images';

shell_exec("ls -1 $folder > oldnames.csv");

$dirlist = file('oldnames.csv', FILE_IGNORE_NEW_LINES);

$count = 1;

foreach($dirlist as $oldname) {
 $newname = 'product-keyword-' . sprintf('%05d', $count) . '.jpg';
 shell_exec("mv $folder/$oldname $folder/$newname");
 shell_exec("echo '$oldname,$newname' >> newnames.csv");
 $count = $count + 1;
}

echo "Done.\n";

?>

script_output.png
 

Attachments

  • script_output.jpg
    script_output.jpg
    17.3 KB · Views: 3
You mentioned wanting to record the old and new names for each file. I was bored so I wrote a script to do it in PHP actually. Just put it somewhere with a directory called "images" and it'll do what you want inside that folder plus log the old and new names. I understand that you are on Windows but hey I'm trying to learn PHP on Linux right now so... :D (This taught me about printf() and sprintf(), yay!)

Code:
<?php

$folder = 'images';

shell_exec("ls -1 $folder > oldnames.csv");

$dirlist = file('oldnames.csv', FILE_IGNORE_NEW_LINES);

$count = 1;

foreach($dirlist as $oldname) {
 $newname = 'product-keyword-' . sprintf('%05d', $count) . '.jpg';
 shell_exec("mv $folder/$oldname $folder/$newname");
 shell_exec("echo '$oldname,$newname' >> newnames.csv");
 $count = $count + 1;
}

echo "Done.\n";

?>

That's awesome... Is this only good for Linux?
 
That's awesome... Is this only good for Linux?

The way he wrote that script, yes, it would only work on linux. You can reproduce the desired actions using native PHP functions though and it should be cross platform.

...longshot, but if you have Ruby, I could whip something up
 
Go grab a copy of Irfanview (www.irfanview.com) It's got a kick as batch renamer as well as batch resize/ resample etc

Simply the best bit of freeware I have ever used - I've got some sites that require me to upload 500 - 1000 pics per day. Irfan view is the tool of choice for all my basic graphic stuff.
 
Go grab a copy of Irfanview (www.irfanview.com) It's got a kick as batch renamer as well as batch resize/ resample etc

Simply the best bit of freeware I have ever used - I've got some sites that require me to upload 500 - 1000 pics per day. Irfan view is the tool of choice for all my basic graphic stuff.

So, the final results now that I've had a chance to sit down and compare the methods (busy weekend):

The Windows UI solution came close to working. 3815 out of 3832 files renamed in order, but for some reason 17 of the files (for reasons I can't determine) were renamed as duplicates of the first 17 images.

It came out something like this:

file00001.jpg
file00001(2).jpg
...
file00017.jpg
file00017(2).jpg
file00018.jpg
file00019.jpg

So, close but no cigar, I tried this a few different ways and couldn't get it right. I'm assuming it's a problem with my input images, not with Windows, but regardless I couldn't solve my problem.

*************************************

I would have checked out the PHP solution, I'm assuming I could make that a .php file on my server in the directory with my images and get it to work, but I'm not handy enough with PHP to know if it would work the same on a server as it would on a desktop like Ubuntu. Never got a chance to try, though, because I used the last suggestion:

*************************************

I checked out IrfanView. No idea how I've never come across this before, but it did exactly what I needed it to. It reminds me of an imaging version of CDex for mp3/wav processing. Anyways, File > Batch Conversion fixed my problem. I initially tried a Batch Conversion and Renaming the Output images but had trouble, and solved my initial problem by just renaming the images with product-keyword-#####.jpg as my file name template.

Worked great, rep clicked for everyone that left a suggestion, thanks to all.
 
OTTOMH:

Code:
(c=1 && find . -name \*.jpg | while read FILE; do
mv "$FILE" product-keyword-$c.jpg
echo "$FILE",product-keyword-$c.jpg
c=$((c+1))
done) > product-keyword.csv

That's in Bourne shell...