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:
# The host and port of the source server
# The user credentials on the source server (username:password)
#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"
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

Post Cleaning Step:

1) Run Data store garbage collection see or 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 for better parsing of response.


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

  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.

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

  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 ?

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

  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

  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

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

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

  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!

  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.

  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

  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

  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.

  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 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.

  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

  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

  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 to help you make the best choice.

  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.

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

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

  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 review and find the writing service you may rely on.

  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: