Sarah
Sarah

Reputation: 1303

ADF Get Metadata only get files, not folders

In my azure data factory pipeline, I am trying to get only the files in my dataset path but when it executes it brings in folders and files together. I have a metadata activity followed by ForEach which needs to only go through the files not the folder.

In my Field list of get metadata activity, I have Child Items listed . In my foreach activity, I have @activity('Get All Files in Folder').output.childItems is there. In my dataset file path I only have path to the folder listed.

Thanks for your help.

Upvotes: 0

Views: 2793

Answers (3)

Joel Cochran
Joel Cochran

Reputation: 7758

Another option is to add a Filter action after the GetMetadata:

enter image description here

In the Filter, you specify the item().Type as 'File' and any other pattern you wish:

enter image description here

enter image description here

Then the ForEach loops over the results of the Filter:

enter image description here

Upvotes: 2

Vio
Vio

Reputation: 11

Most likely all the files have the same extension - for example csv. In this case you can go to 'Get Metadata' activity -> Settings -> Dataset -> fileName and filter only the *.csv

Upvotes: 0

JayashankarGS
JayashankarGS

Reputation: 8150

Add If-else activity inside the ForEach activity with below condition.

@equals(item().type,'File')

enter image description here

And add your activities you needed if it is file type.

Output:

Below is the files in directory.

enter image description here

SetVariable executed 5 time as there are only 5 files.

enter image description here

and enter image description here

Upvotes: 0

Related Questions