Hi there.
What would be the best way to increment version number at the end of a variable?
I have "Project Alpha v1" and want it change to "Project Alpha v1.1", "(...) v1.2" etc. etc.
Thanks!
Hi there.
What would be the best way to increment version number at the end of a variable?
I have "Project Alpha v1" and want it change to "Project Alpha v1.1", "(...) v1.2" etc. etc.
Thanks!
While certainly not the "best".
This is a basic way:
Increment version number.kmmacros (3.6 KB)
If you want to make sure your version number is always a certain number of decimals. ie: v1.00, or whatever, you can explore using the Calculate Token
Additionally, if you want this to work with other base names, you'll have to either modify the regex, or create a regex that is less specific.
Someone beat me, but here's my solution...
Increment Last Number or add .1 Macro (v11.0.3)
For my coding projects I have three separate variables for semantic versioning. MAJOR, MINOR and PATCH
Whenever I need to increment any one of those it’s for a specific reason. If I increment MINOR. I zero out PATCH. If I increment MAJOR, I zero out MINOR and PATCH.
I then concat them as:
“v{MAJOR}.{MINOR}.{PATCH}”
Important question -- what's the version number after v1.9
? You'll see that the macros above give different answers. I've gone with @Airy's assumption that it will be v1.10
Increment Point Version.kmmacros (4.2 KB)
But mainly a bit of fun doing the calculation inside the "Search and Replace"
I highly recommend reading that over if you’re considering versioning best practices.
It’s by no means perfect. But it’s at least a good starting point if you don’t already have your own consistent strategy
Potted version of the advice I give our folks, who are mainly concerned with Word docs and the like:
My Document v1.docx
My Document.docx
because you won't know if you forgot to add, or maybe deleted, the version numberMy Document v01.docx
My Document v01.01.docx
My Document.docx
The padding means they'll get a "proper" alphanumeric sort on platforms less smart than macOS. And step 5 means the finalised document is always top of the sort order, plus is less likely to trigger "multiple extension" alerts if they email it to someone.
I'm late to the party here, and you've gotten several great and sensible solutions already, but still I'd like to share this little quirk of an approach, all within a single KM text field:
version .1 up.kmmacros (16 KB)
That's cool. Some nice tricks in there. For the record, you can put all that into a single line, like this:
Very cool!! Thanks so much!