Hi, for the orphans there is something native. Search Data Administration in Tell Me, inside there is Delete Detached Media. Behind it sits the Media Cleanup codeunit in the System Application, you can call it from your own code as well, it returns the detached media and deletes in batches. Came around 23.5 and it's barely documented. Careful though, I seen few reports where the scheduled cleanup took away more than orphans, item pictures and document pdfs included. Restore a sandbox copy and run it there first, not straight in production.
But detached media is usually not the big part. I'd look at what is still attached, sent email attachments, incoming documents, attachments on posted documents. Retention policies plus deleting from the owning table is the safe way, you never touch Tenant Media directly.
Blob offload is doable but fully custom, and the audit trail becomes your problem after. How big is the environment now?
Glad to help - follow up if anything is unclear.
► If this solved it, marking it verified helps others too.
Regards,
Grigorios Mavrogeorgis
Business Central Consultant & AL Developer
Work: Gmsoft Limited
Blog: insidebusinesscentral
LinkedIn: linkedin.com/in/gregorymavrogeorgis