How to Delete All Assets That Aren't Used After Development

2 replies
Last updated: Sep 27, 2021
During development I needed to add a lot of assets that are not necessary any longer. Is there a way to delete all assets that aren't currently used?
Sep 27, 2021, 10:17 AM
Hi
user T
, this snippet should let you do exactly that 🙂 https://github.com/sanity-io/sanity-recipes/blob/master/snippets/deleteUnusedAssets.js
Sep 27, 2021, 10:33 AM
Works like a charm. Thanks!
Sep 27, 2021, 10:34 AM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?