Don't miss a freebie, deal, or new release.Join Now!
banner with headshot and name

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.