I'm new to AEM please let me know if anyone has idea on below scenario.
I'm working on dam assets - I would like to delete assets from one particular folder after some specific time So Im using scheduler for this requirement, but wanted to know how to get all assets from a folder So that once i get list of assets from folder will try to read the jcr:data of all assets like modified date and based on that will delete the asset once it completes some time in dam.
please suggest if approach is not correct
path will be something like this :- /content/dam/folder
You can utilise the JCR API. The JCR API allows you to query nodes in the JCR with the "JCR_SQL2 search queries". I have provided an example for you below where we are querying for all JCR node-type [dam:AssetContent] under the path "/content/dam/my-project". If results are returned, then we will print each jcr:lastModified (the dam:AssetContent node composes of the jcr:lastModified values). Making a query like this is awesome because you don't need to worry about nested folders.
Before the implementation code, you should familiarize yourself with JCR_SQL2 queries. You can test your queries directly from http://localhost:4502/crx/de/index.jsp; tools (drop-down menu item) > query. A tutorial for JCR_SQL2 query language for beginners can be found here: https://sourcedcode.com/aem-jcr-sql2-tutorial-and-examples-and-cheatsheet. I hope this helps.