Referring to my earlier post – Restructuring-the-tridion-blueprinting-and-content-demotion – another issue while doing demote is the fact that you won’t be able to demote simply by selecting the root folder and demote everything inside – you actually need to go to the deepest level of the hierarchy and starts with the leaf of the content hierarchy – which is absolutely pain to go in each and every folders in the hierarchy and do the demote and there is another issue which might still result in fail if the item in the folder is having a dependency on another item in the hierarchy.
To resolve this, we at Content Bloom created another core service script which accepts tcm uri of the folder which we want to demote along with all its item and the publication uri of the target publication to which we want to demote.
As a second step (refer the above referenced post and This Post if you need a background of this series of blog) in this massive demote exercise, we execute this script to start the actual demote process. The script will go almost blind to start the demote process traversing each and every item in the folder and perform demote in a cyclic manner- this might fail or this might succeed – but ensure to resolve dependency of items with in the same folder with every cycle, ultimately reached to a stage where either all items are demoted, or are just handful of them left with dependencies which needs manual intervention – like checkout, localized version, cyclic references etc.
A few screen shots of the scripts are shown as below for the better understanding of its operation: