how to check for part of file name string if present and set variable as true using ADF

Harshith Kuradha Rajappa 6 Reputation points
2022-07-12T09:36:17.823+00:00

Im getting child values ( all file names) using Get Metadata stage, i want to check if all my files are present by using only with part of the files name (ex if my file name is 2022_07_01_abc.txt,2022_07_01_cbd.txt,2022_07_01_dqf.txt i want to search if this file is present by searching "abc","cbd",'dqf") and if all my files are present then set the variable as true.
how to achieve this using ADF

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,652 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Bhargava-MSFT 31,261 Reputation points Microsoft Employee Moderator
    2022-07-13T21:27:16.023+00:00

    Hello @Harshith Kuradha Rajappa ,

    Welcome to the Microsoft Q&A platform, and thanks for posting your query.

    You are looking to use set variable as true if your folder childitems contains "abc","cbd",'dqf" in the fiepath. Please correct me if my understanding is wrong.

    You can use GetMetadata and If condition to achieve this.

    On the pipeline level, I have written isfilepresent string variable.

    220545-image.png

    I have used Getmetadata activity from the activities section and pointed the dataset to the blob storage(CSV).
    on the field list, I have used child items in the arguments

    220546-image.png

    Connect the getmetadata activity to the if condition. I have used the below expression on the activates pane.

    @ANDO (and(contains(string(activity('Get Metadata1').output.childItems),'abc.txt'),contains(string(activity('Get Metadata1').output.childItems),'cbd.txt')),contains(string(activity('Get Metadata1').output.childItems),'dqf.txt'))

    Inside ifconditon -->True activities, I have used set variable.
    If my expression is true, I am setvariable1 else using set variable2 (for False activities)
    220534-image.png

    220500-image.png

    220563-image.png

    220581-image.png

    I hope this helps. Please let us know if you have any further questions.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.