I've a folder with a lot of files, growing over time. This files has been uploaded and linked in pages. Then the link has been deleted or changed in the pages but the file is still there.
I would like to delete all the unlinked files. I know there's a relation that list all linked files. Do you have some tool/script/catalog query that can find unlinked files? I would say all the files without a isReferencing entry in the relation catalog but maybe I'm overlooking the problem. Thanks for any info/pointer!
That would cover almost 99% of the candidates to deletion. My goal is to have a list of them, and give the list to editors, with a note "to delete as summer tasks" that they will love...
If your files are outside Plone, then isReferencing won't help.
In this case you could search your documents/pages, extract the links (e.g. with plone.app.linkintegrity.parser.extractLinks) and check if links exist (e.g. with urllib or requests or directly in your filesystem)
Furhtermore and depending on the amount of work to do you could offer a customized page that lists the documents/pages with invalid/missing links for the current user.
Yes, this is basically is what I'm going to do. I'll take a look on how api.relations.get works so I can implement a catalog query.
I've always thought that there should be some "lost content" functionality in Plone, to quickly find content (mostly files and images) uploaded but not referenced anywhere. But this can be 99% solved adding the file and images directly to the objects, as Volto does already for example.