Path as a Variable that +1's

Hello!

Is there a way to make a variable that would be equal to a path like..
/Users/Desktop/01/0001

Then when I Run my Macro it adds +1 to the path each time it completes a repeating loop...

So like...

/Users/Desktop/01/0002
/Users/Desktop/01/0003
/Users/Desktop/01/0004
/Users/Desktop/01/0005

and so on.

Thank you!

This is just an example to help get you started. You will need to use as an example and/or change to meet your workflow automation needs.

Please let us know if this meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Increment Number at End of String [Example]

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/e/1/e1cdae806ba4122830f7c0cb764d9140ba07e9f2.kmmacros">Increment Number at End of String [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**


---

### ReleaseNotes

Macro Author:  @JMichaelTX

This is just an example written in response to the below KM Forum Topic.  You will need to use as an example and/or change to meet your workflow automation needs.


**MACRO SETUP**

* **Carefully review the Release Notes and the Macro Actions**
  * Make sure you understand what the Macro will do.  
  * You are responsible for running the Macro, not me.

**==USE AT YOUR OWN RISK==**

* While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
  * **Ask first**
  * Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Topic Title:	Path as a Variable that +1's

URL:  https://forum.keyboardmaestro.com/t/path-as-a-variable-that-1s/16785

Date:	2020-01-25
Posted By:	beansalad

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

<img src="/uploads/default/original/3X/9/3/932b8f95d689a7f861de52a37aec6f1d99c62a68.png" width="646" height="1300">

This is amazing thank you! I will test it out today and get back to you.

@JMichaelTX This works great! One question I do have is how do I get it to reset back to 0001? I noticed even if I enable and disable it the path picks up from where it left off instead of resetting to 0001.

Thank you!

At least two ways to reset the Global Variable DND__Seq_Path:

  1. Delete the Variable in the KM Preferences > Variables pane
  2. Write another macro, or add an option to the existing macro to delete or clear the Global Variable.
    • Use a different trigger, or a long-press keystroke, to trigger the same macro.
1 Like