Retrieve specific number of files based on excel column


I have a folder containing a set of files that I would like to send out and an excel sheet with the column “quantity” determining the number of files that I like to send out at a time. I am quite unsure of the logic of getting the bot to retrieve the set number of files based on the number in excel. As the files in the folder are generic itself, the bot should be able to retrieve the number of files till the said number in the excel is matched. For example if the “Quantity” column in excel stated “5”, then the bot should be retrieving 5 files from the folder. I have been looking through the forum but have yet to encounter such similar issue, is there any way to go around this?


1 Like


If Quantity column value set to 5 in excel then you want to take 5 files from the folder right. Is this mean you want to take particular 5 files or any 5 files ?

Hi @lakshman,

Any 5 files.


Then try below expression.

    getFiles [] = Directory.GetFiles("Folder path").Take(count)

Var count value is coming from Excel file and it is of type Integer.


@Eddie, Below Workflow may help you,
SendingFilesToMail.xaml (10.8 KB)

@lakshman and @Manish540 thanks for both your help! @lakshman it worked, thanks!

1 Like

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