Have a MacBook Pro 15 (Oct2009 vintage), and am running 10.8 (Mountain Lion).

Is there an easy way to search for and replace chars in JPG file names in a folder file list?

I'm working with over 70,000 JPG images, and close to 1000 duplicate names must be corrected. My preferred solution is to simply change the name prefix of each from 642 to 699. None of my 3 image browsers/editing programs can do this. I've already spent more time looking for an automation solution, than changing them 1 at a time would have taken, but would prefer an automation approach if there is one. The finder search function works great, sadly there doesn't seem to be a replace function to go with it. I'm not a programmer, so am hoping there is something built that might do the job.

  • Normally I would suggest Automator, a bashscript or the command-line tool rename (installable via brew) but since you said you are not a programmer I assume you will be more comfortable with a (paid) rename app from the App Store though I see the problem that most of the programs would not let you search for duplicates for renaming.
    – Pfitz
    Dec 17, 2012 at 8:11
  • Can you describe the directory structure of the files? Are the files that have to be renamed in some specific subfolders?
    – Lri
    Dec 17, 2012 at 8:12
  • NameChanger is a nice little App for renaming files, it might be helpful
    – Jason
    Dec 17, 2012 at 16:44

2 Answers 2


Finder is not the tool for this job, but I've always done this sort of thing via Terminal.

To be safe, you should have a backup of your Mac since the mv command will rename everything it finds, and if more files match the "642*" pattern, they will get changed as well.

Here is a snippet of code to get to the folder, find the files starting with 642 and do the edit one by one in an automated fashion. (Obviously changing the path to the real location of your images):

cd "/path/to/your/images"
for i in 642*; do
    mv "$i" "${i/642/699}"

This will move all images matching the wildcard 642* (meaning it starts with 642 and the rest of the name can be anything), and moves them in order to rename the 642 to 699. It will overwrite any files that already have the destination file name, so be sure that they are files you don't want.
This assumes that you don't organize your images into subfolders too; change 642* to */642* if this isn't the case.

  • (trying again to get readable formatting) You can add a test to avoid overwriting. Here is an example all in one line, and note that I have the command "echo" in front of the mv command. I use this to show what it will do, then if it looks correct, I rerun the same command with the "echo" removed: for f in 642*; do echo mv $f 699${f#642}; done Note that I also used a different form of variable modification. This is a ksh/bash specific form, so if you use different type of shell, this may not work.
    – Tim B
    Dec 17, 2012 at 15:04
  • I shouldn't comment before coffee. I left off the test I was commenting to suggest: for f in 642*; do [ ! -f 699${f#642} ] && mv $f 699${f#642}; done
    – Tim B
    Dec 17, 2012 at 15:20

If you don't want to use the Terminal or Automator, there are commercial apps with a GUI for doing this. One is A Better Finder Rename, which has a free trial version (no need to pay if your renames are for less than 10 files).

You can also search the App Store for the term "batch rename" and see that more than 9 apps look designed to solve that problem. The three that have 10 reviews each and positive star ratings seem to be join the long time favorite leading apps at the moment:

I would say that these three alternatives cost less but haven't been around as long as A Better Finder Rename which has worked well for me.

  • I wanted to reinforce Wheat's recommendation with some alternatives - all on the App Store, but ABFR is software I've seen many people need to upgrade to, but never outgrow. Several pro photographers use it to wrangle 10,000 files a weekend regularly as part of their ingest workflow.
    – bmike
    Mar 29, 2013 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .