Wednesday, December 12, 2012

How to remove non referenced node from DAM in CQ 5.5

Use Case: Clean your DAM to remove non referenced node.

Solution: You can use following script to remove all non referenced node from DAM.

# !/bin/bash
# Author: upadhyay.yogesh@gmail.com
# The host and port of the source server
SOURCE="localhost:4502"
# The user credentials on the source server (username:password)
SOURCE_CRED="admin:admin"
#Filter path
ROOT_PATH="/content/dam/<Your PATH>"
ALL_PATHS=`curl -s -u $SOURCE_CRED "$SOURCE/bin/querybuilder.json?path=$ROOT_PATH&type=dam:Asset&p.limit=-1" | tr ",[" "\n" | sed 's/ /%20/g' | grep path | awk -F \" '{print $4 "\n"}'`
echo "$ALL_PATHS"
for SINGLE_PATH in $ALL_PATHS
do
REFERENCE_COUNT=`curl -s -u $SOURCE_CRED "$SOURCE/bin/wcm/references.json?path=$SINGLE_PATH" | tr ",[" "\n" | sed 's/ /%20/g' | grep path | awk -F \" '{print $4 "\n"}'`
if [ "$REFERENCE_COUNT" == "" ] ; then
  echo "Removing $SINGLE_PATH"
  #curl -u $SOURCE_CRED -F:operation=delete $SOURCE$SINGLE_PATH
fi
done

Post Cleaning Step:

1) Run Data store garbage collection see http://www.wemblog.com/2012/03/how-to-run-online-backup-using-curl-in.html or http://helpx.adobe.com/crx/kb/DataStoreGarbageCollection.html for that)
2) Remove these nodes from publish as well if they are not deactivated already (usually deleting activated node should delete it from publish as well, But please check)

Caution: As always please test this. Also this might not cover Image referenced through CSS or your code. This only covers Image referenced through Image or Image related component.

Note: You can also use JSAWK https://github.com/micha/jsawk for better parsing of response.


27 comments:

  1. I'm blinded by the pure awesomeness of this script! :)) Thanks a lot!

    ReplyDelete
  2. This site is truly amazing my one of friend told me about this. And the theme is quite beautiful as well as the updated stuff also attract visitors to come and visit again. I would definitely bookmark it and would come back to you soon. Keep on updating.

    ReplyDelete
  3. Any example of how this can be done from a java class

    ReplyDelete
  4. Hi,
    This script will work for CQ5.6 as well ?
    And If I want to recreate this script to remove only videos from DAM, what change I could make ?
    Regards

    ReplyDelete
  5. Is it possible to get batch file equivalent for this script as my CQ is running on windows.

    ReplyDelete
  6. Do you need an assignment expert in Australia? Quit looking now, we are giving modest writing services to understudies. You can procure proficient scholastic scholars from Australia for your assignment. Our writers are accessible whenever you can contact at Australiaassignmenthelp.com.

    ReplyDelete
  7. Our assignment help experts could address students' academic topics quite well. Thus, they can opt for our service if they have difficulty in writing the academic task.
    assignment help

    ReplyDelete
  8. great and informative blog. Thanks for sharing..
    AllAssignmenthelp Reviews

    ReplyDelete
  9. Your information is absolutely correct and accurate. Thanks. assignment help

    ReplyDelete
  10. Do my cpm Homework? Our CPM homework helpers use accurate problem-solving strategies to come up with the right answers to each question in this course. Stuck with the questions in the course 1 of CPM? Get CPM homework help from us now!

    ReplyDelete
  11. ABC Assignment Help is an incomparable online Accounting assignment help company delivering excellent academic assignments, essays, coursework and reports. Through a team of over 3000 subject experts we ensure individual attention to every student making the assignment help experience completely personalized in nature. With our round the clock services, you can be assured of high grades every time.

    ReplyDelete
  12. Wow!! Great information you provide in your blog of Assignment Help. It gives me idea to write my assignment in effective and presentable manner. It really helps me a lot to score good grades at lower price. It is helping me in getting good academic ground. Experts are GEMS.
    Assignment Help Online
    Online Assignment Help
    Assignment Help Online Services
    Assignment Helper
    Assignment Assistance
    Assignment Help Experts
    Online Assignment Help Services

    ReplyDelete
  13. Having an assignment due tomorrow and understand you can’t do it yourself? But you’re afraid of delegating your paper to some scam services as well? Why not check edubirdie reviews on Scamfighter.net

    ReplyDelete
  14. Installation of Fashion Telecommunication Camera specializing in consulting, surveying and installation of CCTV systems Camera Wifi IP in Binh Duong, Binh Duong for households, shops, shops, corporate offices and factories.

    ReplyDelete
  15. Our team is officialy working 24x7 to offer you best service. Our team is having amazing knowledge and they are offering you all the assignment service so you can get by simply visiting studentsassignmenthelp.com. One of the best and latest service you can get here. Stop who are demanding for stats homework help, it's they you can easily get on our website.

    ReplyDelete
  16. Make a duplicate of the generation occurrences (creator and distribute). For instance with the CRX reinforcement Assignment Writing Service - Assignmentspot instrument Extract the reinforcements in a testing situation Start the occasions as is and debilitate the replication operators - so as to keep away from superfluous obstruction with the creation condition

    ReplyDelete
  17. Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. essay help

    ReplyDelete
  18. Whether you’re planning to explore all opportunities, consider the job you really wanted in the first place, or just move up the career ladder, we may provide you "whitbread review" on Resume101.org to help you make the best choice.

    ReplyDelete
  19. Academic writing subjects help is most trust able Nursing assignment help from the writers of Singapore Assignment Help. Get cheap assignment help form our writers at affordable price with higher grade in your academics.

    ReplyDelete
  20. Way of presentation in your article is most impressive. assignment help australia

    ReplyDelete
  21. Get help in making your assignment and essay from the expert guidance on students assignment help. StudentsAssignmentHelp.com provide assignment & essay help Perth service to the students.

    ReplyDelete
  22. Your essay is too difficult and you need some help? Hiring somebody on the Internet doesn’t sound like a good idea? At EssayTopicsMasters we have found a solution to your dilemma. Check out https://essaytopicsmasters.com/reviews/homeworkmarket-com review and find the writing service you may rely on.

    ReplyDelete
  23. Are you looking for CHEAP TRANSLATION SERVICES SINGAPORE? You are at right place. Our Certified, Trusted, Fast & High Quality translators are available only for you at very affordable prices. For more details you can fetch us at email: info@singaporetranslators.com.

    ReplyDelete