Thanks for your patience. Since you would like to preserve the hierarchy of the folder structure but would like to just rename the file names in those folders, that best and efficient (cost & performance) approach would be to utilize Copy activity for copying files to destination using CopyBehavior = PreserveHierarchy
feature and once the copy is completed then have a custom activity or Azure function or an Azure Databricks notebook where you can write a custom code to deep traverse through the folders and subfolders and rename the files as needed.
The reason I recommend going with custom code for renaming the files is because, If you would like to do this in a regular ADF pipeline, then it requires total of 4 pipelines and each pipeline contains minimum a GetMetadata activity, ForEach activity, Inside ForEach we need another GetMetadata activity and followed by an Execute pipeline activity and the flow looks like below:
- ParentPipeline1 - > GetYearFolderNames -> ForEachYearFolder -> GetMonthFolderNames - >ExecuteMonthLevelPipeline
- ChildPipline1 - > ForEachMonthFolder->GetDateNamesForEachMonth->ExecuteDateLevelPipeline
- ChildPipeline2 -> ForEachDateFolder -> GetFileNamesForEachDateFolder - >ExecuteFinalFileCopylevel
- Final_ChildPipeline3 - >ForEachFileName-> CopyEachFileWithRenamedFileNamePreservingHierarchy
Above will be the high level flow. I did try it out a sample with few folders and files and noticed that the performance is not as expected as the overall flow involves multiple activity executions. If I have this business requirement, I wouldn't prefer this approach as it is not cost/performant efficient while there is a better way by copying the files as is preserving folder hierarchy using copy activity and then will try to implement some custom code/application to just rename the files in those folders.
Hope this info helps.
Please don’t forget to Accept Answer
and Yes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.