Safely deleting File Assets from dotCMS

32 views
Skip to first unread message

Stewart Turner

unread,
Nov 1, 2021, 11:02:25 AM11/1/21
to dotCMS User Group
Hi everyone

I've been tasked with a data cleanup exercise across our site, and need to identify which of our File Assets are currently in use on the live site, so that the rest can be deleted.

Does anyone know how to achieve this?

Other content types have the 'References' tab available so that you can see if a page is using the asset, but the File Asset doesn't have such an option.

My question is really is there any way of checking whether a File Asset is being used on a page?

Any help VERY gratefully received :)

Thanks

Stewart

Daniel Silva

unread,
Nov 4, 2021, 10:47:00 AM11/4/21
to dotCMS User Group
Hey Stewart, 

If using the Java API is an option then you have available the MultiTreeAPI. The multi_tree stores the relationship between pages-containers-content, so you could call
com.dotmarketing.factories.MultiTreeAPI#getMultiTreesByPage which returns a list of `MultiTree` objects, each containing a contentlet under the "child1" param. Then you 
could load the contentlet and filter by type. That way you can build a list of files being used by pages and use it accordingly to your final goal. 

Daniel

Stewart Turner

unread,
Nov 9, 2021, 6:16:25 AM11/9/21
to dotCMS User Group
Thanks so much Daniel! I will investigate :)
Reply all
Reply to author
Forward
0 new messages