SOLVED Bulk rename Tags with a LUA script


I have several ase files with a massive amount of tags, and I have to rename all the tags in every files.

I would like to do it in LUA, but I don’t really know where to start, or if it’s even doable.
Could someone help me out to get started ?

Thanks !


Hi @Arkogelul, you can do that kind of work. One possibility would be to create a script that iterate through all open sprites and then all tags of that sprite. For each tag you can change its property.

Thanks David,

I’m really new to LUA so I might not do the right thing.
So far I have this :

local sprite = app.activeSprite

for i,tag in ipairs(sprite.tags) do = test

But nothing happens. No error nor warnings.

Try changing this to: = "test"

It works !! Thanks :slight_smile:

So now I have this :

local sprite = app.activeSprite
local name1 ='^(.+)bad$')
local badTagName = nil

if name1 then
badTagName = tag.sprite.tags[name1 .. " bad"]

local function modifyTag(1) = " good"

if badTagName then

That obviousely didn’t work. I gathered some piece of code here and there, not at random, but not really knowing if it fits together. It gives me this error :

attempt to index a nil value (global'tag')

Basically, I would like to look for a particular string in the tag name, and if the string is in the tag name, change it with another one.

change the word ‘adult’ for the word ‘kid’ would give

I think the issue here is the 1 in the list of arguments of modifyTag, try this:

local function modifyTag(tag) = " good"

Anyway to get the desired result you are looking for something like this I guess:

local function modifyTag(tag) = name1 .. " good"

Using the name1 part of the name but changing bad with good.
I hope it helps!

Thanks a lot, once again.
I found a solution that works :slight_smile:

local sprite = app.activeSprite

for i, tag in ipairs(sprite.tags) do

local name = = (string.gsub(name, "old string", "new string"))


Hi @Arkogelul! ^^

Would you mind sharing the final script so I can add it to this thread?

I don’t mind at all. The final script is in my last post. I’m planning to improve it a bit though. I’d like to add an interface and the ability to add a string before or after. I don’t how to deal with the interface yet. I will have to check on this.


Thanks! I went and made that interface for you! :wink:


Also I uploaded to a github repo for Aseprite scripts, I hope you don’t mind :slight_smile:

You can download the script here.


OMG you’re amazing! Thank you so much :grinning:

I’m glad you liked it! :smiley:

I went and added also the prefixes and suffixes functionality ^^



Haha! You’re great :grinning_face_with_smiling_eyes:
Thanks again, that is very thoughtful of you.
I’m glad to contribute to that great community.

1 Like