Condition to check downloaded file


I am downloading files from email attachment to a folder.I need to move the file based on condition

  • Condition is if the file downloaded name contains ABC and extension is .xls or .xlsx then do the job else delete the file.
1 Like

We can do that with a ASSIGN activity and IF condition

Now use a ASSIGN activity like this once after downloading all the attachments from the mail inside the loop
arr_Files = Directory.GetFiles(“yourfolderpath”)

This will give all the files in that folder

Now use a FOR EACH activity and pass the above variable as input and change the type argument as string
—Inside the loop use a IF condition like this
NOT item.ToString.Contains(“ABC”) or item.ToString.Contains(“xlsx”) or Split(item.ToString,”.”)(1).ToString.Contains(“xls”)

If true it will go to THEN part where we can do our process or it goes to ELSE PART where we can use DELETE FILE activity where pass the input as item.ToString

Cheers @indrajit.shah

1 Like

@Palaniyappan i have a bit confusion with the if condition as i have to look three things for then -

  • 1st Filename contains ABC
  • 2nd and 3rd File extension .xls and .xlsx
1 Like

Yah this would work for sure
Cheers @indrajit.shah

@Palaniyappan Sir unfortunately it didn’t worked from me…
I need to do the job only if all criteria meet but instead of that its its going to then for any file name any extension, see the screenshot

1 Like

then remove the NOT condition
which means if any of the condition is met it will go to THEN part or goes to ELSE part
Cheers @indrajit.shah

1 Like

already tried :slight_smile: but there is one small issue its if the file name is anything but extension is xls or xlsx its going to then.
I think i have to use two IF condition in 1st part i have to filter with item.ToString.Contains(“ABC”) and 2nd item.ToString.Contains(“xlsx”) or Split(item.ToString,”.”)(1).ToString.Contains(“xls”)

i guess it will work perfectly, handling all the condition is raising conflict.

1 Like

Fine split the if condition into two IF condition
That would work for sure
Use first if condition and mention like this
And if true it will go to THEN part where we can use another IF condition like this
item.ToString.Contains(“xlsx”) or Split(item.ToString,”.”)(1).ToString.Contains(“xls”)

Kindly elaborate a bit more on the condition we need if this doesn’t meet our requirements

Cheers @indrajit.shah

1 Like