Hi Wasim,
Thanks for reaching out to Microsoft Q&A.
Try thte following approach which will allow you to maintain a flat folder structure in the sink container based on file ext. while scanning files from a complex hierarchy in the source container.
- Get Metadata Activity:
- Use a
Get Metadata
activity to recursively list all the files in the source container. In this activity, set the option to list the "Child Items" to retrieve all files, including those in subfolders.
- Use a
- Filter by Last Modified Date:
- In the
Get Metadata
output, you'll have details of each file. Use aFilter
activity to filter files based on thelastModified
property. The filter condition can be set to include only those files whoselastModified
date is earlier than your specified date.
- In the
- For Each Activity:
- After filtering the files, use a
For Each
activity to loop through the filtered files.
- After filtering the files, use a
- Determine File Extension:
- Inside the
For Each
, use anIf Condition
orSwitch
activity to check the file extension (for ex:.csv
,.xml
, etc.) and create the appropriate path for saving in the sink container based on the file extension.
- Inside the
- Copy Activity:
- Use a
Copy Activity
to copy the files from the source to the sink container. In the destination container path, dynamically build the folder structure as:container/somefolder/allfilesinhere/<extension>
- Use a
- File Name Mapping:
- In the copy activity, you can use dynamic content expressions to map the file names appropriately and avoid copying the folder structure. For example, in the sink's file path, you can use expressions to concatenate the year, month, and day based on the file's last modified date, and the file's extension for organizing files.
This approach ensures that the folder structure from the source is not recreated in the sink. Files are saved based on their extension and last modified date in the desired format.
Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.