This is an example script for deleting assets that aren't linked in your content model. It does this by walking through all assets and checking for any links back to them.
WARNING: This script does not take into account assets that are only linked inside of Text fields. If you primarily embed images directly using the markdown editor, this will very likely delete assets you depend on.
You must fill in your own CMA access token & space ID at the top before running
git clone git@gist.github.com:/afc97da1869f5fb3aef1.git cleanup-assets
cd cleanup-assets
# Edit index.js to set up your credentials
npm install && npm run cleanup-assets
Np :) However I should add, that you probably have to run this script multiple times to delete all unlinked assets.
And I think this is the reason:
(red squares are unlinked assets that are to be deleted, and green squares are assets that should be kept)
So there's room for improvement if someone wants to give it a go :)