Where are my Resources?
One neat feature about MCMS is the ability to replace resources without the need to scour through all HTML pages to update hyperlinks. Once replaced, all postings that point to it immediately reference the most updated version of the resource. It's a total self-help module where Resource Managers have total ownership over their files. They don't have to bug developers any more about getting that document updated. Neat, eh?
Well, not quite. They still call. Before replacing a resource, resource managers want to know the pages on the site that are linked to it. Is the resource being used? If not, can it be deleted? Otherwise, where will it be seen? Will anything bad happen to them and their computer if they replaced/deleted the file?
And here's the point where I usually give that little smile and politely say, "I have no idea..."
Well, not any more. After being bugged a hundred times by resource managers asking what they should do with a ballooning collection of resources, I've decided to do something about it.
I have here, a script that scans through the entire site for a list of resources that are linked from placeholder content.
It uses a simple recursion to look for occurences of /NR/rdonlyres/ and grabs the GUID that comes after it. (Well, I could have used a pattern that matches GUIDs instead, but this allows me to filter out links to non-resource objects like channels and postings and potentially include files added as local attachments).
Once a resource is found, it writes to a CSV file:
- path of the resource
- path of the posting and
- name of the placeholder that contains a link to it.
The script is good for a one-time scan. The next step would be to add some custom code in the workflow event handlers to scan placeholder content for links to resources when postings get published.