I need to change the names of my tags within a UDT to something more cryptic. But I want to copy the current name to the documentation before I make the change. I have several hundred tags in each UDT and several dozen UDTs. Is there a way to loop through each tag in a UDT in a script?
You'll probably need to use system.tag.getConfiguration
in conjunction with system.tag.configure
.
I think something like this should work. I just renamed the tag name to be _ OldTagName _, so you can replace with your aliasing llogic.
udtFolderPath = "[default]_types_/SomeUDTs"
udtDefs = system.tag.browse(udtFolderPath)
for uDef in udtDefs:
print uDef
tagConf = system.tag.getConfiguration(uDef["fullPath"], True)[0]
for tag in tagConf["tags"]:
tag["documentation"] = tag["name"]
tag["name"] = "_%s_"%(tag["name"])
system.tag.configure(udtFolderPath, tagConf)