If folder contains certain file

Hi all,

I am trying to find out if in a certain folder (fixed folder), minimum one file exists that ends with “bis.xlsx” and contains “status”.
That would be an if condition to start performing certain activities.

Thanks in advance,
Kind regards,
Y.

Hi,

you can use the Path Exists activity to check for a specific file. The file name can be dynamically specified…

If you want to check for multiple files, you can use Directory.GetFiles(“FolderPath”) to check whether there are any files available. You can use this in an Assign activity.

Hope it helps :slight_smile:

1 Like

@yannip
Use assign statement with an array(of string) variable in the left side and Capture on right hand side.

The outcome will be the file names matching the criteria in the specified folder.

Hope this helps!
If this resolves your issue, please mark it as solution so that people facing similar issues can directly navigated to answer.

2 Likes

Hi @yannip,

You can use this condition for the ‘if activity’.

Directory.GetFiles("Folder_Path").Where(Function(n) n.Contains("status") and n.EndsWith("bis.xlsx")).Count >=1

Warm regards,
Nimin

2 Likes

This solution does the trick with the less modifications for me.
One more thing, sometimes user save the file with “status” or “Status” or “sTatus”. How could I make sure I capture the capital letters as well?

Thanks!

Hi @yannip,

Please use this condition.

Directory.GetFiles("Folder_Path").Where(Function(n) n.IndexOf("status",stringcomparison.InvariantCultureIgnoreCase) <>-1 and n.EndsWith("bis.xlsx")).Count >=1

Warm regards,
Nimin

2 Likes

Perfect, works like a charm.

Thanks

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.