Quickly organize tags into folders

I was in the market for a faster way to organize tags from a bulk import and wasn't able to find an existing example.
Manually organizing through drag and drop was very time consuming and I found out the hard way that dragging too many tags at once would lead to locking up the program. so I came up with a script to handle this.

1.) In the script console (Tools>Script Console), paste the script below.
2.)Change the sourceFolderPath and destinationFolderPath to your desired paths in quotes.
3.) Change the keyword of the tags you want moved in the 'if " " in tagName:' line
4.) Hit execute and the tags should change locations.

# Define the root folder paths
sourceFolderPath = "[default]_device 1_/UnitId xx/AllTags"
destinationFolderPath = "[default]_device 1_/UnitId xx/AllTags/Outputs"

# Get a list of all tags under the source folder
tags = system.tag.browse(sourceFolderPath)

# Iterate through the tags and move those containing "Output" in their name to the destination folder
for tag in tags:
    tagName = tag['name']
    if "Output" in tagName:
        # Move the tag to the destination folder
        tagPath = sourceFolderPath + '/' + tagName
        system.tag.move([tagPath], destinationFolderPath)
2 Likes

Please see Wiki - how to post code on this forum and then fix your post.

Got it, Thanks!

1 Like