MacMost Now 312 : Batch Rename Multiple Files

Learn how to rename a batch of files using Automator in Snow Leopard. You can quickly and easily create a workflow that will allow you to select a group of files or a folder and rename the files replacing or adding text, adding numbers or the time or changing the file extension.

Comments: 18 Responses to “MacMost Now 312 : Batch Rename Multiple Files”

    Randy Clark
    14 years ago

    Great Automator tip! I'm a long-time Mac user, but have never gotten into using AppleScript/Automator but this might inspire me to finally jump into it. One related question to this tip: is there any way either thru Automator or some 3rd party Mac apps to re-name a bunch of files RANDOMLY? I frequently add new photos to my digital frame's SD card, and while the frame supposedly has a random-display mode, it's never worked. I'd like to take my photo files for the digital frame and randomly rename the files (using number prefixes). I've searched several times over the past few years to find some way to easily accomplish this on a Mac, but failed to turn up any viable options. Any ideas?

      14 years ago

      You should be able to do that with AppleScript, yes. But I'm not sure of the exact code off the top of my head, sorry.

      Lorelei
      14 years ago

      I was looking for a way to do the exact same thing, for the same reason; I found this in searching for it. Failing, though, I wrote the AppleScript to do it. I thought I'd share, in case you were still looking for a way:

      (*
      This is a script to append random numbers to the beginnings of file names. Originally created for the purpose of randomizing pictures for adding to a digital frame.

      It will, as the warning says, rename original files rather than creating copies. But hey, it warns you first!

      Written 16 Dec 2009, by LoreleiF
      Written in Snow Leopard, but should be good at least down to Tiger.
      *)

      tell application "Finder"

      set theFolder to (choose folder)

      display dialog "WARNING: This will NOT create copies of your files - it will rename the originals. Continue?" buttons {"Yes", "No"} default button "No" with icon caution

      if the button returned of the result is "Yes" then
      set theFiles to (get every item of theFolder)

      repeat with i from 1 to count of theFiles

      set oneFile to item i of theFiles

      set the name of oneFile to ((random number from 1 to 1000) & (the name of oneFile) as text)

      end repeat

      end if

      end tell

    Dick Franks
    14 years ago

    Very useful!

    On a recent trip my wife and I each took 400 photos using our two cameras. Now I can place the 800 photos in the same folder without a Duplicate Name conflict, such as IMG_1234 being created by each camera. It also allows quick identification of the author.

    Like Randy, I'm inspired to get further acquainted with Automator.

    Scotty
    14 years ago

    Hi. Before Snow Leopard, I was able to have a simple renamer action appear in my Finder right-click menu.

    Since I updated to Snow Leopard, I don't see that option. What happened, and how do I get it back?

      14 years ago

      Just select a file and press the Return key on your keyboard. Alternatively, you can select the file, wait a second so it isn't a double-click, and click on the name of the file. Both will then allow you to edit the name.

        Scotty
        14 years ago

        What I meant was, the renamer was only one of the Automator functions I had on my right-click menu.
        It was Right-Click/More/Automator/renamer (or something similar)

        I had a few functions I liked having in that menu, but I don't get 'More' on the right click menu any more.

        Thanks for the reply. I'll hang up and listen.

          14 years ago

          It sounds like maybe you had something installed that gave you that functionality? Perhaps you installed a piece of third-party software that gave you some functions like that.

    Jefe del Fresco
    14 years ago

    Awesomely helpful tutorial. I didn't even know I had something called Automator. Gary, you just saved me a tedious hour today, and many more in the future. Thanks!

    bronek
    14 years ago

    VERY USEFUL!! THX!!!

    John Forstall
    13 years ago

    Excellent tutorial

    Hugh
    13 years ago

    Great tutorial Gary, very helpful. Out of interest is there any was of setting automator to prompt for the user to enter the new filename text as part of the workflow rather than having to edit the workflow itself each time? Many thanks

      13 years ago

      Yes. You can ask for text, you can ask to find a file, all sorts of things. Look through the Automator actions and experiment.

    Phil Jordan
    12 years ago

    Hi Gary

    Love your newsletter, and your archive of videos is a real comprehensive library of tutorials that I have benefitted from many times. Thank you. With this Automator sequence, can you ask it to look into folders and sub folders? Rather than having to select files within one folder at a time?

    I need to batch rename approx 1.2TB of audio files all grouped into artist/title folders.

    Thanks
    Phil

      12 years ago

      Im pretty sure there is no way to do that as an Automator sequence. But as AppleScript it should be possible. But not easy, unless you are a programmer and have either experience or time. Lots of steps and a big learning curve.
      Maybe purchasing a batch rename application is the more efficient way to do it.

      Aaron
      12 years ago

      Phil, It's really too bad he didn't cover recursion. Oh well. Back to google.

    Phil Jordan
    12 years ago

    Hi again Gary

    Thanks for your quick response. I thought I should report back that I have persisted with this and I think I have found a work-around. So for anyone else doing something similar to me, you can try this:

    Select the Automator processes as per Gary's video, click 'Run' and instead of choosing files within a folder, spotlight the file extensions within the master folder (in my case I spotlight ".wav" within the master folder "Music"), than select all.

    There are approx 24,000 tracks on my NAS drive (all CD quality or above), so my MacBook Pro struggled to handle the task. I am currently running it through an iMac which seems to be working, but it may take a couple of days more!

    Kind regards and thanks again for your videos!

    Cheers
    Phil

    Dave
    12 years ago

    Worked for me with Lion (02/2012) but I had to replace all the quote marks with quote marks from my keyboard (SHIFT+") since the existing code quote marks are 'out-of-bounds' for Lion.

Comments Closed.