Save "filename plus one". Example: "Project 1.bla" will be saved to "Project 2.bla" in Ableton Live 12

Hi ! I'm super new to keyboard maestro and i love it so far.
I'm trying to do something that must be doable easily.
Have a custom action in my program to save as a new version file in Ableton Live 12

So the thing would be for "ProjectName 1.Als"
Magic shortcut would save it to "ProjectName 2.Als"

I already have the begining with "Save as" shortcut + the right arrow that goes at the end of the file name, before the ".als"

The hard part would be to delete the previous value like "7" and turn it to "8" for exemple, or "20" and turn it to "21" ( two numbers)

Is that doable somehow ? Thanks a lot :slight_smile:

Try it the other way around:

  1. Get the name of the document
  2. Add 1 to whatever-the-number-at-the-end is
  3. In the "Save as..." dialog, replace the entire suggested name with the new name

You can usually get the name of the active document with the %FrontWindowName% token.

Thanks a lot ! Really new to this, so what are the type of actions i should use and stuff, can you give me a bit more detail on how to achieve this ( got the software yesterday) thanks a lot really appreciate :slight_smile:

Start by having a skim of the manual, then casting your eye over the Actions, Tokens, and Functions wiki lists. You don't need to learn it all(!), but it'll help if you know some of the terminology, have an idea of what's available, and know where to look when you need to dive deeper.

After that -- every macro starts with an Idea followed by a Plan. You've got your Idea, so the initial Plan might be something like:

When I do a certain keystroke in Ableton I want to "Save As..." the current document, changing the name to either add <space>1 if its name doesn't end in a number, or increasing the existing number by 1

You then refine the Plan, often by doing the thing manually and taking notes as you go:

  1. Trigger the macro with ⌃⌥S
  2. Select the "Save As..." menu item
  3. Change the file name, either adding <space>1 if it doesn't end in a number, or incrementing the number already there by 1
  4. Click the "Save" button

You then refine those steps, breaking them down further until you get to KM Actions. You've previously mentioned that the file name is selected when the dialog opens -- that's an easy way to get it so you can add/change the number. So Step 3 expands to:

  1. Pause until the "Save As..." dialog appears
  2. Copy the file name onto the Clipboard
  3. If the name on the Clipboard does not end with a number
    5a. then append %Space%1 to the string on the Clipboard
    5b. otherwise replace number at the end of the name with number + 1
  4. Paste the new name into the dialog

By which time you should be able to use the various pages linked above to add the appropriate Actions etc to your macro. There are two tricky bits here -- you could have started with something easier! -- which are:

  1. Getting the number, which is best done with a Regular Expression
  2. The "Save As..." menu item ends with an ellipsis, not 3 periods, and that's caught all of out at one time or another :slight_smile: Use the "Select or Show a Menu Item" action's "Menu" picker to get the correct item:
    image

Putting that all together, using TextEdit since I don't have Ableton:

Incremental Save As.kmmacros (6.0 KB)

Image

Change the first Action so it targets Ableton's menu item, see if it works. And ask if anything isn't clear.

Thanks a lot for taking the time to answer ! I think i've found a way to do that ! I'm gonna test it and see if it works, thanks so much for explaining to me, i'll report here if everything works as expected :slight_smile: