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.


45 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
  24. Being an academic writer from past 5 years providing assignment help to college and university students also associated with Myassignmenthelp platform. I am dedicated in providing best online academic writing services to the college students at the affordable rates.

    ReplyDelete

  25. Studies show that around 56% of all students consider their homework as the most primary source of stress in their life. It is no wonder then these students constantly think of ‘who can do my homework ’ in UK. Fortunately for them, we provide expert homework help at very reasonable prices. Recent research has also revealed that on average students between the ages of 6 to 17 have to spend a little more than three and a half hours each day of their school life doing homework. Our aim is to cut the time you spent doing your homework by more than a half by offering homework online services in UK to students. We offer you with several extraordinary benefits that make us the best choice for you. Homework help uk

    personal statement writing
    ghostwriter
    coursework help

    ReplyDelete
  26. Writing a medical school personal statement is a rite of passage for future doctors and physicians. Nursingessaywriting.com offer you personal statement medical school samples. That you well studying in nursing specialty.

    ReplyDelete
  27. Truly decent and intriguing post. I was searching for this sort of data and appreciated perusing this one. Continue posting. A debt of gratitude is in order for sharing. assignment writing service

    ReplyDelete
  28. Excellent post. This article is very helpful for the people and also for me. I get the some useful knowledge in this post. Thanks for sharing the informative topic, by the way. all assignment help reviews

    ReplyDelete
  29. Download and install Vidmate App which is the best HD video downloader software available for Android. Get free latest HD movies, songs, and your favorite TV shows.

    ReplyDelete
  30. Nice blog. We provide better and most popular Assignment Help Online to our customers. This is a legal and reliable company. My professional assignment help online is well qualified to complete academic content for our customers. Assignment Help Online

    ReplyDelete
  31. Hi! I am Martinlutharz, available 24x7 to help out the needy ones who are suffering from issues related to their Apple devices. Whenever, you face any type of technical or non-technical issue associated with your Apple device, you can give a ring to ourApple Support Phone Numberat anytime and also from anywhere. Here, I and one of my colleagues will provide you get cent percent resolution for your entire issues within a quick succession of time.

    ReplyDelete
  32. Your information is very detailed and useful to me, thank you for sharing. I hope you will always be up to date. We also provide affordable MBA Assignment help in uk.

    ReplyDelete
  33. Singaporetranslators.com offers DOCUMENT TRANSLATION SERVICES SINGAPORE. We only use native professional translators who use less time to clear things. Our minimum charge is depending on the length of paper and type of papers. We provide affordable and reliable services to our customers.

    ReplyDelete
  34. Online assignment help Australia In A Click-PhD Experts 24/7
    Why choose us? We got 24/7 live support with 1450+ assignment expert with years of experience. 100% unique content with on time delivery. Instant online essay help with flat 20% off on your first order. Grab the deal now.
    Stop here! Get best macroeconomics assignment help online -order now
    Key features - 100% plagiarism free, on time delivery, 100% satisfied customers

    ReplyDelete
  35. Worrying for your essay? @GotoEssayHelp, we provide ultimate help with essay at very affordable prices. Our major focus is on satisfied students. Top class professional write my essay are now available to you in a click at best rates possible.
    Its time you avail our best in class MBA Essay Help and nursing essay help with the help of PhD native experts available 24/7 only for you.

    ReplyDelete
  36. GotoDissertationHelp – Perfect station for your dissertation help online.
    One of the best portals for your dissertation writing help with the help of native PhD experts. We provide marketing dissertation help in very affordable rates keeping your pocket money in mind.
    What are you waiting for? Jump on to GotoDissertationHelp for top quality HRM dissertation help with flat 30% OFF on your first order.

    ReplyDelete
  37. Get Your printer issues fixed with our third party printer support team,if you have issues like HP Printer not printing it is a very common issue and can result from many dissimilar reasons like; missing or out-of-date drivers, faulty connections, bad configurations in Windows,etc. simple things like no ink or a paper jam can cause frustration with HP printer not printing.

    ReplyDelete
  38. I was redirected to this blog. I pressed the combination of words julie thao and here I am. It was not waste of time. I enjoyed reading this article.

    ReplyDelete
  39. My Assignment Services Australia is Best Place to Make Your Best Assignment. We have a team of highly qualified assignment experts who always ready to help you with your assignment. We provide a lot of type assignment services regarding your assignment. Our aim is to provide the best online assignment help in Australia.

    ReplyDelete
  40. You can go to approach for Epson Support to look out the expected change in it. With the association of this facility, an individual can check how much ink remain in printer before starting the printing work. A number of Epson wireless printer setup fluctuations come into real time action and no user has any idea to recover its error as quick as possible. . However, a few persons are facing technical issues in their Epson printer and can’t be able to recover its disorder within defined time. Any user is not compelled to accept its technical hindrance. In urgent situation, you can browse our web portal and support Epson error code 0xf1.

    ReplyDelete
  41. Very nice blog!!! This is really good blog information thanks for sharing. We are a reliable third party Garmin GPS Update company, offering technical GPS support for various types of technical any types solve errors.

    ReplyDelete