Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Script to Mass Update Numbered Tokens?

I've run into a situation a few times where I have a group of similar tokens that are all numbered (using TokenNameNumber ), but then I decide that I want to change all of the names in the same way without losing the numbers. Currently I've been just doing this manually and individually with a TokenMod command. For example, if I've prepared a map with a group of Cultists, and then I realize that I don't actually want to name them all 'Cultist 1, Cultist 2, ...' because my players don't realize they are part of the cult yet, it would be really handy to be able to change just the 'Cultist' part in bulk on all the tokens.  Or other times I simply want to shorten a long name such 'Heavily Armored Statuette 1' to just be 'Statue 1'.   I'm trying to adapt this awesome script  to just affect the token names, but I'm stuck on the syntax for isolating the current token name and swapping out only a specific portion. Any help would be appreciated!  
1674246781
Andrew R.
Pro
Sheet Author
Have you tried doing it in 2 steps? Make them all the same name using the TokenNameNumber template and then renumber them?
1674251185

Edited 1674251604
Andrew R. said: Have you tried doing it in 2 steps? Make them all the same name using the TokenNameNumber template and then renumber them? Isn't it easier to just write a custom script instead of a macro that can do it using already available scripts?  Kidding! I hadn't considered doing it that way!  Thank you... sometimes it's easy to miss the trees for the forest. Here's what works for anyone else who needs to do the same thing (using TokenMod and TokenNameNumber): !token-mod --set name|"?{New Token Name?|@{selected|token_name}} %%NUMBERED%%" !tnn --renumber It won't preserve the current numbers on the tokens, but that isn't a big deal as I'm mostly concerned about setup prior to my players on the map.  I could probably tinker with Fetch or whichever of Timmaugh's metascripts to do this on an individual basis to keep the number if I need that in the future.
1674251573
The Aaron
Roll20 Production Team
API Scripter
You could rename them all using TokenMod: !token-mod --set name|"Foo %%NUMBERED%%" --ids @{CharacterName|character_id} Then have TokenNameNumber renumber: !tnn --renumber That doesn't preserve the same numbers, but it would allow you to do the rename easily.
1674264749
Andrew R.
Pro
Sheet Author
Ninjas!