Select a group of files in Finder and press the Hot Key trigger. Without incrementing the counter, each file would end up with -1 as the suffix. Add a Set Variable to Calculation action and have it Set Variable FileNameCounter to FileNameCounter+1. The final thing to do is have the FileNameCounter variable cycle by one.
Pay attention to the punctuation there is a hyphen between the call for the BaseFilename variable and the call for the counter and there is a full-stop (period) between the counter and the extension. Set it to Move %Variable%Path% to %Variable%BaseFilename%-%Variable%FileNameCounter%.%Variable%FileExtension%. Next add a Move or Rename a File action directly beneath the Get Extension action. A For Each Path action is what cycles through each file. This tells Keyboard Maestro to store the extension of the file you’ve imported as a variable.
It will cycle through each file that you pass to it and perform the same series of actions on each one. If you don’t select any files, it will just crash.Ī For Each Path in Finder Selection action is a kind of Control Flow action. For the macro to run, you'll need to select a group of files in Finder before pressing the Hot Key trigger. Add a For Each Path in Finder Selection action. Once things are set up the files can be pulled in. This both gives us the counter variable and resets it every time the macro is run. Give it the variable name FileNameCounter and have it set to 1. You’ll also find it in the Variables Category. Next add a Set Variable to Calculation action. Click the Green Plus icon to add a new variable. That counter also needs to reset to 1 every time the action is run.Īdd a New Action and select Prompt for User Input from the Variables Category. Second, it needs a counter so that it can add the sequence number to the end of each filename. This macro needs to do a few things before it loads in any files.įirst, I need some way to tell it what to name each file. I’ve gone with Command-Option-Shift-R for the trigger because it’s not used by Finder already. Give it a name like Rename Files and a Hot Key trigger. Open Keyboard Maestro and create a new macro.
It costs $36 for a full licence (which I obviously think is well worth it) and there’s a free trial so you can get a feel for the app before buying it. You’ll also need a copy of Keyboard Maestro.
It’s a relatively simple macro but it nicely demonstrates the basics of working with files. Tuts-1.jpg, Tuts-2.jpg, Tuts-3.jpg and so forth.
In this tutorial, I’m starting with the very basics by showing you how to create a macro that renames a group of files so that they all have the same base name followed by a sequence number, e.g. Over the next few tutorials I’ll show how you can work with files in Keyboard Maestro. One thing I haven’t covered yet, however, is how to use Keyboard Maestro to work with files in the Mac’s file system. I’ve looked at everything from creating simple keyboard shortcuts to macros that automatically Tweet whatever you’re listening to on Spotify. So far in my tutorials on Keyboard Maestro, I’ve covered a huge number of the app’s features.