Assets which are longer than one month. | Community
Skip to main content
April 20, 2022
Solved

Assets which are longer than one month.

  • April 20, 2022
  • 1 reply
  • 544 views

Hi , 

I am new to Aem. is there any Query to find the assets based on some conditions? In my case, I need to Move the assets that are jcr:created is more than one month ago using Scheduler. That scheduler should run every week.

and 

for moving we have AssetManager.moveAsset() but is there any sample code how to use that api programmatically?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Bhuwan_B

@venki105 you can implement it using Query Builder API and make use of predicate relativedaterange.

sample query to get all assets that are modified 5 days before (Test using Query Builder Debugging Tool)

http://<host:port>/libs/cq/search/content/querydebug.html


path=/content/dam/wknd-events
type=dam:Asset
relativedaterange.property=jcr:content/jcr:lastModified
relativedaterange.lowerBound=-5d  (If no upperBound is specified, it is treated as 0, indicating current time)
p.limit=-1

Referencehttps://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-query-date-range-property-to-query/td-p/378971

 

1 reply

Bhuwan_B
Community Advisor
Bhuwan_BCommunity AdvisorAccepted solution
Community Advisor
April 20, 2022

@venki105 you can implement it using Query Builder API and make use of predicate relativedaterange.

sample query to get all assets that are modified 5 days before (Test using Query Builder Debugging Tool)

http://<host:port>/libs/cq/search/content/querydebug.html


path=/content/dam/wknd-events
type=dam:Asset
relativedaterange.property=jcr:content/jcr:lastModified
relativedaterange.lowerBound=-5d  (If no upperBound is specified, it is treated as 0, indicating current time)
p.limit=-1

Referencehttps://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-query-date-range-property-to-query/td-p/378971