Example: We have a folder filled with 30 images with inconsistent names. These images need to be named consistently and numerically: image1.jpg image2.jpg image3.jpg ... image30.jpg Can this be automated?

  • And which criterion would the files be named after? How do you choose the sequence? – slhck Aug 28 '12 at 16:32

Hazel monitors folders for changes and can rename newly added files. Commercial with full-featured demo.

Hazel watches whatever folders you tell it to, automatically organizing your files according to the rules you create. It features a rule interface similar to that of Apple Mail so you should feel right at home. Have Hazel move files around based on name, date, type, what site/email address it came from (Safari and Mail only) and much more.


Name Mangler is a file rename utility. Just drag & drop files on the program window and set the rules. The preview shows how the files will be named afterwards. Commercial with full-featured demo.

The Finder is good at a lot of things, but renaming a lot of files is not one of them. Enter Name Mangler, which makes short work of all your file renaming tasks.


Your Mac comes with Automator, a tool allowing you create so-called workflows.

With Automator you can automate much of what you do with your computer. Create and print a family directory with the contacts in your Address Book. Find and add images from your favorite websites to iPhoto. Print your documents to your iPad. Instantly rename dozens of files in the Finder.

Launch it, and select to create a new workflow. From the Library, add a Get Specified Finder Items action and a Rename Finder Items action (don't create copies of the files when asked about it). Drop & drop files on the first action to add them to the workflow. Configure the second as shown to Make Sequential with new name and separated by nothing. Run by pressing the "Play" button in the toolbar.


To do this from the command line in bash, enter the parent directory and run the following command:

declare -i C=1 ; for file in *.jpg ; do mv "$file" "image$C.jpg" ; C=C+1 ; done
  • There's also Renamer (renamer.com) and A Better Finder Rename (publicspace.net/ABetterFinderRename) – Karolos Aug 28 '12 at 17:01
  • c.f. Batch change file extensions in Mac OS X? – slhck Aug 28 '12 at 17:29
  • @slhck Thought about it, but this seems to just be about sequential naming, the other about normalizing file extensions. The Automator solution wouldn't work there. Maybe it's time for a canonical "I want to batch rename files" question? – Daniel Beck Aug 28 '12 at 17:51
  • With the full Automator treatment? Would be nice. Or make it a blog post ;) – slhck Aug 28 '12 at 18:22
  • How about the command line? Do I really need to deal with another app and ui to accomplish this? – Fresheyeball Aug 28 '12 at 20:15

You can use a shell command like this:

i=1;for f in *;do echo mv "$f" image$((i++)).jpg;done

Remove echo if the output looks right.

Another option is to run brew install rename and then run rename -n '$_=$N.".jpg"' *. Remove -n if the output looks right. $N is the file number starting from 1, $_ is the current line, and . is used for string concatenation in Perl.

More examples:

i=1;for f in *;do mv "$f" $(printf %03d $i).jpg;let i++;done
i=1;for f in *;do mv "$f" $(printf %03d $i).${f##*.};let i++;done
IFS=$'\n';i=1;for f in $(ls -rt);do mv "$f" "$((i++)) $f";done
for f in *.mp3;do mv "$f" "$(printf %02d ${f%% *}) ${f#* }";done
for f in *;do b=${f%.*};x=${f#*.};mv $f ${b%-*}-$(printf %03d ${b#*-}).$x;done
shopt -s extglob;for f in !(*.*);do mv $f $f.txt;done
for f in *;do mv "$f" "${f//[^a-zA-Z0-9.]}";done
rename 's/.*ep(..).*/Example EP$1 720p HDTV x264.srt/' *.srt

${f##*.} removes the longest *. pattern from the start and ${f%.*} removes the shortest .* pattern from the end. ${f//[^a-zA-Z0-9.]} removes all characters except [a-zA-Z0-9.].

  • You could also use something like ruby -e 'Dir["*.png"].each_with_index { |f, i| File.rename(f, "prefix #{i}.png") }' Worked perfect! – Philip Jan 28 '14 at 9:16

Driveby answer, in case someone lands on this page in the future: Yosemite (OSX 10.10) added batch-renaming to the finder, so now all one has to do to perform such operations as OP's is select all the files that need renaming, right/control-click on them, and select Rename X items....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.