Expand my Community achievements bar.

SOLVED

Assets which are longer than one month.

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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