File creation with variable

I am working on a macro that should allow me to quickly create textfiles that all have some predefined content. I can figure out almost everything, but what I’m struggling with is how to use a variable I created, which holds the next number the textfile should get and use it in the file creation.

I have files that look like this:



…and so on

So basically I’m just counting upwards. The naming pattern for these files is clear: zettel-$nextnumber. But how do I get KM to create a file in the first place (it seems I could duplicate one) and how do I use variables while naming files? Is it necessary to use a script for that (I guess something like touch zettel-$nextnumberwould work)?

So you want to create empty text files?

Sorry, posted before I finished.

So if you want to create an empty text file, you could do something like this:


Oh, that works? Well, should’ve checked that. :wink: And no, the files should’ve some content, but I can just add that to the now empty box there. Thanks!

LOL. Get used to that feeling. KM does a million things (it seems), so it's easy to overlook things. Happens to me constantly.

Yes, you can put variables practically everywhere in KM. Even in the text box in this action, if you wanted to do something custom.

Glad to help.

This post should help:

1 Like

A post was split to a new topic: Create Files with Sequential File Names

@ccstone (Chris), I moved your macro post to a new topic in the "macro" category so that it will be easier for all to find. It is a great example of sequential file numbering.