Check number of files, files name and send email

FileName

Hi Robot Master,

Please help.
I would like to use UiPath to send email, when the number of files (for eg; there should be a toal of 5 files) with the file name starting with RPM, are already available in the folder.

How can i do it?

Thank you.

Hey @Joanna2

Use a for each file in folder activity to iterate through all those files which has RPM in the starting
use RPM* in the folder path
And inside for loop use a count variable to count files
If count=5 then send mail
I have attached the file below for reference

Testtt.zip (3.0 KB)

Hope it helps you

Hi @Joanna2

=>Take assign activity and create a count variable with int datatype and initialize as 0.
=>Take an For each file in folder activity and in the filter give *.xlsx.
=> Inside for each file in folder place the IF condition write the condition as below

CurrentFile.Name.StartsWith("RPM")

=> Inside If give assign activity increment the count. Count = Count+1
=> Use Copy file activity to copy these to some dummy folder. It will use to send this filtered files to the mail easily.
=> Outside for each use If condition to check the Count = 5
=> In then block give the mails activities to move forward in the automation.

Check the below image for better understanding.

Hope it helps!!

Hi @Joanna2

Use this expression in the assign activity to get the array of files:
arr_Files = System.io.Directory.GetFiles("C:/FolderPath", "RPM_*.xlsx)

arr_Files.Count gives the number of files count.

Use for each loop to iterate through array:
Path.GetFileName(currentItem) 'To get the file name
send mail by passing current item to argument in the mail property.

Hope it helps.

Hi, i tried the method, but it keeps sending the “Testing fail” email, which means there’s no 5 csv files in the folder. But there’re 5 csv files in the folder though. Something gone wrong with the count?

Please help! thnaks

In second If condition don’t give any activites in else block.
In first If condition place the copy file activity to copy those files in to a dummy folder.
Then the CSV files copied in to the dummy folder .

In send mail activity provide the dummy folder path in folder option

Check the image I have attached above once.

Hope it helps!!

Hi, the files seems to be corrupted. Not able to open…

@Joanna2
Refer below Workflow screenshot

Find the below image it has workflow. please check it let me know.

Hope you understand!!

@Joanna2

You can simply try this:

@Joanna2

Please try these steps

  1. Create a variable ls of type array(of string)
  2. Use assign activity ls = directory.GetFiles("FolderPath","RPM_*.csv")
  3. Now use if condition with ls.Count=5
  4. On then side send an email and in attachmnets pass ls

Cheers

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