A small script to rename attributes’ types. It tested on 5k media.
[Gramps SuperTool script file]
version=1
[title]
Rename separate media attributes' types in Supertool
[description]
This script checks each media attribute for any value containing "familysearch". If the attribute key is "URL", it renames the key to "Familysearch URL" and prints the updated key and value.
[category]
Media
[initial_statements]
# Initialize a counter to keep track of updates
count = 0
[statements]
# Retrieve the list of all media attributes
attribute_list = obj.get_attribute_list()
# Iterate through each attribute in the list
for attr in attribute_list:
# Get the attribute type (key) and value
key = attr.get_type()
value = attr.get_value()
# If the value contains "familysearch" and the key is "URL", rename the key
if "familysearch" in value.lower() and key == "URL":
# Set the new key to "Familysearch URL"
attr.set_type("Familysearch URL")
count += 1
# Print the updated attribute information
print(f"{count}). ID: {gramps_id}, Key: '{key}', Value: '{value}'")
# Print a summary of the total number of updates made
print(f"Total updates: {count}")
[filter]
[expressions]
[scope]
# Apply the script to all media objects
all
[unwind_lists]
False
[commit_changes]
# Commit changes after processing
True
[summary_only]
False