import bpy
class GU_OT_property_remove_all_in_file(bpy.types.Operator):
bl_idname = "property.remove_all_in_file"
bl_label = "Remove ALL Custom Properties from the file"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
for attr in dir(bpy.data):
if "bpy_prop_collection" in str(type(getattr(bpy.data, attr))):
for obj in getattr(bpy.data, attr):
for custom_prop_name in list(obj.keys()):
del obj[custom_prop_name]
return {"FINISHED"}
def draw_op(self, context):
self.layout.operator("property.remove_all_in_file")
if __name__ == "__main__":
bpy.utils.register_class(GU_OT_property_remove_all_in_file)
bpy.types.VIEW3D_MT_object.append(draw_op)
Then search for "Remove all custom properties from the file" using the search tool (F3 by default) or go to Object > Remove ALL Custom Properties from the file.
You can also directly run this in the script editor
import bpy
for attr in dir(bpy.data):
if "bpy_prop_collection" in str(type(getattr(bpy.data, attr))):
for obj in getattr(bpy.data, attr):
for custom_prop_name in list(obj.keys()):
del obj[custom_prop_name]
If you want to remove properties with a specific name from all items in the file, use :
import bpy
for attr in dir(bpy.data):
if "bpy_prop_collection" in str(type(getattr(bpy.data, attr))):
for obj in getattr(bpy.data, attr):
for custom_prop_name in list(obj.keys()):
# Use either of these depending on your use case :
if custom_prop_name == "my_prop_name":
# if custom_prop_name.startswith("my_prop"):
# if custom_prop_name.endswith("prop_name"):
# if "prop" in custom_prop_name:
del obj[custom_prop_name]