Removing all meshes from a collection with Python I have 2 collections in a scene (collection, items) both with objects (meshes, camera, lights). How can I select all objecst of type mesh from items and delete them?

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)


With that I can delete all from the scene but I want to limit it to delete all meshes from items. Probably I can if the collection name and type mesh but maybe there is a simpler way?
Don't think there is a simpler way (as you mentioned in the question).

Globally:


Get the collection
Iterate over mesh objects in the collection
Keep its inner mesh data
Remove the object


Then (optional):


Iterate over the collected meshes
Look if it has became orphean (no user)
If yes, delete it


Commented code:

import bpy

collection_name = "items"

# Get the collection from its name
collection = bpy.data.collections[collection_name]

# Will collect meshes from delete objects
meshes = set()

# Get objects in the collection if they are meshes
for obj in [o for o in collection.objects if o.type == 'MESH']:
    # Store the internal mesh
    meshes.add( obj.data )
    # Delete the object
    bpy.data.objects.remove( obj )

# Look at meshes that are orphean after objects removal
for mesh in [m for m in meshes if m.users == 0]:
    # Delete the meshes
    bpy.data.meshes.remove( mesh )