Increase variable with +1

I want to make a simple macro in Logic Pro to bounce/render several files. I have most of it down, but I want KM to increase the number/variable at the end of the filename with 1 each time. How do I do this?

It would help a lot if you could upload the macro in question, but in general, this is how to increase a number variable by 1:


Ok, so yeah, as you assume, this is my first time trying to do a TM macro.
I am trying to name the new folder after cmd+shift+N to 2,3,4 etc

then ideally after that, there is a text input where I would like to have the text that is there already (and ends with a variable (Bumpers 1) to increase the number to (Bumpers 2)


Please upload your macro so we can see the details and test.
See How to post/upload your script/macro.

Firstly, if this is your first macro, you should probably start simply and get a handle on some nice simple macros. Make sure you are comfortable with basic macros that you can make work.

But let’s take a step back, and figure out what you are actually trying to do.

Do you want to make just one folder, or a set of folders? When do you want to make them? Where do you want to make them?

Step back and think about exactly what sequence you want to happen and then we can look at crafting a macro to do it. For example:

  • I want to open a folder in the Finder
  • I want to press the key pad =
  • I want Keyboard Maestro to ask me the base name and count
  • Then I want Keyboard Maestro to create a set of count folders, named "basename 1", "basename 2", … "basename count".

Keyboard Maestro could do all of that, but first you need clarity on what it is you want to do.

1 Like

@peternlewis: Thanks for taking your time. Let me get back to you and try to be a bit more clear.

@peternlewis @JMichaelTX

Ok, just to be clear, this is for automating a work flow in Logic Pro X.
I want to export several different "songs" from one session. I want to export the tracks for each song separately. I want each song to have a separate folder with all the tracks. This can mostly be done with Key Commands/Hot Keys in Logic.
The first song I will do manually, so the script kicks in for the following songs.
From the following script I took out the stuff that didn't work.

  1. Sets the next part to be bounced/rendered
  2. Tells Logic to export the tracks
  3. Tried to make it jump back one folder since default in Logic is to bounce in the most recent folder which means it will make a folder IN the folder for the previous song. (Doesn't seem to work)
  4. Create new folder (Finder shortcut that works within Logic too)
    4B. MISSING - Name folder (automatically)
    4C. MISSING - add +1 to the file name (s) (in text dialogue field)
  5. "Return" exports the tracks

LOGIC PRO X - Export Stems for Bumpers.kmlibrary (4.0 KB)

I've never used Logic Pro, so I can't test this to see if it works, but based on the steps you provided, I've tried creating a more automatic macro that should get you close to what you want (new actions in yellow):

LOGIC PRO X - Export Stems for Bumpers 1.1.kmmacros (6.9 KB)

You will of course need to adjust the parent path in the Create New Folder action to the one where you want to make these new folders, and you'll also need to make sure that the Pause Until action's button condition is correct, and change it as appropriate if it isn't. On the plus side, if this macro works and once you become comfortable with it, you can disable the Prompt for User Input action to stop confirming the bumper number and have the macro create the correct folder name automatically.

Thanks a million, will check right away!

@gglick So I have messed around with this a bit now. The problem is how to create the folders, and where. Ideally I don't want to do this in Finder but through the Logic Pro export dialogue, because that's where it will export the files. If I do it your way, there is no way for Logic to find the new folder created by the script and export the files there.


@gglick Ok, I finally got it to work, by tweaking your version a little bit. It's kind of a hack, and I needed to add pauses in a few places, otherwise Finder was too slow. But yeah, it works anyway! Thanks a million for your help.

LOGIC PRO X - Export Stems for Bumpers 1.2.kmmacros (8.3 KB)

Glad you got it working! In response to

As I said, I've never used Logic, but I assumed that when your macro types B to export the files, it brings up a standard Open/Save file window, like this:

If it did, then this part in my macro:

would set that window to the folder created with the Create New Folder action earlier in the macro, thus allowing Logic to find the new folder. If that's not the sort of window Logic gives you when exporting files, then no, it won't work. Anyway, as long as you've got a solution that works for you and you're happy with now, that's all that matters. Glad I could help!

Thanks! Yeah it does bring up that window, but for some weird reason it didn't work. I am now thinking I could try to put in a short pause somewhere in there and try again, because it gave some really weird results, like creating a folder with the name "~/documents/Logic Pro/Bumpers..." etc.

Is it possible to create a prompt where I set the project path initially? So that it can be different for every project?

Certainly. There's a Prompt for File action just for that. I've updated the macro I uploaded yesterday to include such a prompt and use the resulting variable in the Create Folder action and the action where the path to change to that folder to save the exported files is inserted:

LOGIC PRO X - Export Stems for Bumpers 1.1.1.kmmacros (7.2 KB)

You could also make a separate macro with just this action and run that to set the parent folder once without affirming it every time you run this macro, then run it again whenever you want to change the parent folder path. Alternatively, you could just disable and enable the folder prompt in this macro manually.

The Pause Until action I included in this macro should cause it to wait until the newly created folder path can be inserted properly when exporting, but as I said, you may have to experiment with different conditions to find one that works for Logic, or just use a set pause like you arrived at with your current macro.

Thanks! Yeah ok, the problem is that when Logic has exported a set of files, the "export dialogue" "stays" in the newly created folder, so any new folder will be created in that folder an so on, so they will be "nested" so to speak.

I understand, but if the macro I uploaded works as intended, it should create the new folders in the top-level parent folder without nesting, and set the export dialogue to that new folder automatically.

Testing now!

Ok, so I think I have a set up that works now! I tweaked your macro again, and like you suggested, did 2 separate macros, 1 for the first export, and then 1 for the following. Only the first prompts for folder location. It also doesn't use the Logic Pro Key Command to jump to the next marker.
I am also going to change the second one to not ask for confirmation regarding the export number. It's enough that the first one does that, and if I need to re-export, I "reset" the version number by inputting "1" in the first macro.

LPX - Stems for Bumpers 1.1.2 MAIN.kmmacros (6.8 KB) LPX - Stems for Bumpers 1.1.2 SECOND PASS.kmmacros (6.9 KB)

Again, thanks a million!

1 Like