In Azure Data Factory, what is the process for copying files from a subfolder and appending a the subfolder and timestamp to each file's name in the destination folder?

Orabi, Moussab 20 Reputation points
2023-02-27T19:05:58.64+00:00

Hi all,
I have a folder containing several subfolders, each of which contains files. My goal is to create an ADF pipeline that copies all of these files into one folder and appends the subfolder name and a timestamp to each file's name. I was able to retrieve the file names within each subfolder using the getMetadata activity in a for each loop, but I'm unsure how to copy the files and append the subfolder name to their names. Since a nested foreach loop is not possible, and executing another pipeline with the first loop will prevent passing the output of the second getMetadata activity to the pipeline, I'm unsure how to proceed.

2023-02-27 19_52_23-Presentation1 - PowerPoint

2023-02-27 20_02_24-cl-az-rt-adf-386-01 - Azure Data Factory

2023_02_27_20_03_42_cl_az_rt_adf_386_01_Azure_Data_Factory

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,544 questions
{count} votes

Accepted answer
  1. ShaikMaheer-MSFT 37,896 Reputation points Microsoft Employee
    2023-03-01T16:31:27.5066667+00:00

    Hi moussab orabi,

    Thank you for posting query in Microsoft Q&A Platform.

    You can achieve it using two pipelines. Pipeline1 to get folder names and iterate over them to get file names and pass them to pipeline2. Pipeline2 iterate over file names and copy them to destination. To generate output file name dynamically, use the expressions accordingly in Sink dataset of copy activity.

    Please check below screenshots of my implementation for same.

    Step1: Pipeline1, GetMetaData activity to get folder names from root folder. and iterate over them using ForEach activity and pass the file names to Pipeline2 along with folder name.User's image

    User's image

    Step2: Pipeline2, takes filenames along with folder name and iterate over file names and copies it to destination. In Sink dataset use expression to generate file name according to requirement.

    User's image

    User's image

    Hope this helps.


    Please consider hitting Accept Answer button. Accepted Answers helps community as well.


0 additional answers

Sort by: Most helpful