Join my newsletter for info on upcoming books, classes, appearances, and discounts.Join Now!

Tech Tuesday: Renaming sequential files with the Mac Automator

While writing Scrivener For Dummies, I took a lot of screenshots. I then had to give each figure the same name, but incremented to represent its order of appearance in the chapter. In the beginning I used copy and paste, and then edited the last two digits. But for as many as 20 files?

B-o-r-i-n-g.

My laziness often translates to a search for automation, and this was no exception.

The good news for Mac users? There’s an easy way to rename a group of files all at once, including incrementation: Automator.

Even better, once you set up an Automator workflow, you can save it to use over and over again, just changing the folder or the file name criteria to search.

Here’s how it’s done (click an image for a larger view):

1. Automator is located in Finder under Applications. Double-click to open. You should get a screen like the one below.




2. Select Workflow and click Choose.

3. In the list at the left (under Library), click Files & Folders.

4. From the secondary list, drag Find Finder Items onto the gray workflow space at the right, as shown below.

You’ll set this part up to narrow the list to only the files you need.




5. In the Search drop-down list, choose the lowest level folder you can (as opposed to, say, Computer) to avoid pulling in erroneous files. If you don’t see the folder you’re looking for, click Other in the list and navigate to the desired location.

6. From the second drop-down list, choose All.

This will return all files–and only those files–that match the criteria you specify in the next step. Your choice only really matters if you specify more than one criteria line (steps 9 and 10).

7. In the Any Content drop-down list, choose Name.

8. To the right of that, another drop-down list appears. Select Contains.

Contains searches for the string no matter where it occurs in the file name, but if you’re worried about including files that don’t belong, you can set it up differently depending on how your files are named. If the files you want all start with the same string, use Begins With. If they all end with the same string, use Ends With. Pretty straightforward.

9. In the text box, enter the string of characters that all of the files share.

In my case, they all had “Screen Shot” in them.

10. (Optional) If you have any additional criteria to add–for example, narrowing it down to files created after a certain date, or those with a specific file extension–click the plus (+) button to the right to add another row of criteria. This is where the All, Any, None part actually comes into play.

At this point, we’ve set up the file selection process. It’s a good idea to run it to make sure we’re getting the results we want before moving on. Step 11 shows you how to run the workflow.

11. Press the Run button in the toolbar.

The workflow runs, ending with a beeping/horn sound, and a green checkmark appears at the bottom of the Find Finder Items pane.

12. To see the results and verify they were what you expected, click the Results button at the bottom of the Find Finder Items pane, as shown in the figure below. Click Results again to hide the list.



Now you’re ready to change the name.

13. From the secondary list at the left, drag Rename Finder Items onto the workspace.

Two panes appear: Copy Finder Items and Add Date or Time. The Copy Finder Items pane is there to protect you from yourself by copying the files before doing anything to them. If you feel safer with it there, use it. Otherwise, click the X button to remove it.



14. In the Add Date or Time pane, click the Add Date or Time drop-down list and choose Make Sequential.

The pane changes to reflect options for the Make Sequential operation.

15. Choose New Name, and enter the desired name in the text box. In the example below, I want each file to be named “mybook figure-XXX”, so I typed mybook figure into the text box.



16. Choose whether to place the number before or after the name from the Place Number drop-down list.

17. In the Start Numbers At text box, designate the starting number. If you want three digit numbers, starting with 001, just enter 1 here, and specify the number of digits in step 19.

If you need something longer–like say all figures for chapter three start with 03–enter 301 here and make it four digits in step 19.

18. From the Separated By drop-down list, choose the desired separator, if any. I chose a hyphen.

19. To make all numbers equal length, click the Make All Numbers check box, and then type the number of digits in the text box.

Note the example shown at the bottom of the Make Sequential pane. If it doesn’t look like what you wanted, play with the settings until you get it right.

20. Click Run.

Automator runs both sequences and then beeps. Click the Results box to see your newly renamed files (and/or go check them in Finder). Note that the files are sequenced based on the alphabetical order of the original file names.

21. (Optional) To save the workflow for future use, go to File–>Save.

TIPS

  • To add additional text to the beginning or end of a file name, choose Add Text from the Add Date or Time drop-down (instead of Make Sequential).

    You can even do this as a third step in the workflow (after Make Sequential) if you need to make the files sequential and then add something after them, such as “annotated”. Just drag Add Date or Time to the workspace under the Make Sequential pane.

  • To rename only a portion of the file name, choose Replace Text from the Add Date or Time drop-down list.

0 Comments

  1. Reply

    Like most good things in life, you have to apply them vs. just read about them! I find your knowledge of the mighty Mac and, of course, Scrivener, amazing. I am sure I will use this tip eventually, just so much to absorb being a new Mac user. Thanks.

  2. Reply

    I agree, Dorothy. I have to try something out and see it work to really get it or hope to remember it. I actually found this procedure when I went looking for a way to change the screen shot location (much more complicated), and it’s saved me a lot of time.

    It took me a while to get used to Mac after so many years on a PC. Don’t be afraid to play and look around. And Apple has some great introductory posts in their Support pages. I always find useful things there. Go to http://support.apple.com and search for Mac 101.

  3. Reply

    Oh, I forgot about this one! I used it when I was temping, saved my mind and soul! So, thanks! It will be perfect for puploading pictures of into slideshows and for web site images -very cool!

    • Reply

      Crisgzr: Saving mind and soul is a great way of putting it. I used to rename groups of files in Windows all the time, so I knew there had to be a way on the Mac. I love how much flexibility and power the Automator provides. Of course, that scares people too. 😉

  4. Reply

    Maybe I don’t understand clearly enough what Automator does—under what circumstances and for what result would one use this in writing fiction (no screenshots, pix, etc)…or is this just another cool thing my iMac apps do that I haven’t a clue about? 😉 So many apps, so little understanding! Thanks, and btw, I’m taking your Scrivenor class in September so if I don’t “get” this, maybe I’ll get that!

    • Reply

      ttthomas: This isn’t specific to writing, just to the Mac. It’s a program that lets you automate all sorts of tasks, but you could go your whole life without using it. 😉 Here’s a good overview if you’re interested: http://support.apple.com/kb/HT2488

      The class should make more sense. See you in September!

Leave Comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: