I haven’t tried to create this script yet but I saw something earlier about deleting sheets not on a schedule. This would be my workaround option but I thought I’d ask first.
Try this: get all the viewports in the project, find out which sheet each viewport is on. Get all sheets in the project, filter out sheets which are in the list of sheets derived from the viewports. Delete the sheets still in the list.
You could also just get the views on each sheet and if there aren’t any delete it.
Ether Jacob’s or Sean’s methods listed above will work just fine. But keep in mind placeholder sheets too. Programmatically they are the same as a sheet but cannot hold viewports. So if you delete all sheets without a view placed then you will also delete all placeholder sheets. There are some nodes to check if a sheet is a placeholder or not if you do not what to delete them too.
Not too much of an issue since I have no placeholder sheets