Hello @Bommisetty, Rakesh
To get the latest subfolder from a main folder using Azure Data Factory, you can use the Get Metadata activity. In the Get Metadata activity, you can specify the metadata type as "childItems" to get a list of subfolders and files in the given folder.
Then, you can use the "lastModified" metadata type to get the last modified datetime of each subfolder.
Finally, you can use a Filter activity to filter the subfolders based on the last modified datetime and select the latest subfolder.
Here is an example of how you can achieve this:
- Create a pipeline in Azure Data Factory.
- Add a Get Metadata activity to the pipeline and specify the folder path of the main folder in the "folderPath" field.
- In the "fieldList" field of the Get Metadata activity, specify "childItems" and "lastModified".
- Add a Filter activity to the pipeline and connect it to the Get Metadata activity.
- In the Filter activity, specify the condition to filter the subfolders based on the last modified datetime. For example, you can use the expression
@greaterOrEquals(item().lastModified, addDays(utcnow(), -7))
to filter the subfolders that were modified in the last 7 days.
- Add a Select activity to the pipeline and connect it to the Filter activity.
- In the Select activity, select the subfolder with the latest last modified datetime. For example, you can use the expression
@last(activity('Filter').output.value).name
to select the latest subfolder name.
- Use the selected subfolder name in subsequent activities in the pipeline as needed.
I hope this helps! Let me know if you have any further questions.