How to get Particular file From directory

hi,
i have some files in folder…

Exp—

  1. Swiggy MPR Monthly----->09 - Swiggy December-2021
  2. Swiggy Cancel File—> 09-Swiggy Cancellation Working December-2021
  3. Swiggy reconcilation File----> 09 - Swiggy Reconciliation Differences December, 2021

i want to get Swiggy Mpr Monthly File . Can any one help how to get this file ?

hi @Anand_Designer

Getting the filePaths of the files within a directory
within an assign activity
Leftside: your Variable of Datatype: String Array
Rightside: Directory.GetFiles(YourTargedDirectoryPath)

please watch the below video fr your reference

Thanks

HI @Anand_Designer

Use Assign activity

LHS → Variable of Datatype → String Array
RHS → Directory.GetFiles(“FolderPath”,“Swiggy MPR Monthly*”)

Regards
Gokul

i want Swiggy Mpr file only .to send this file to out Argument. this file name will be use in other workflow

Hi @Anand_Designer,

Use @Gokul001 approach. You will be good.

1 Like

Hi @Anand_Designer

Try this expression above

Regards
Gokul

hi , i used directory and for each loop . getting each file name .
swiggy MPR monthly file format like-- 09 - Swiggy December-2021.
it might be change for every month --For exp if January come…
10 - Swiggy January -2022.
i want to get this file name dynamically .

i used this condtion but i am not getting exact file name. getting other file name

HI @Anand_Designer

Can you share the exact input file name here

Regards
Gokul

Swiggy MPR Monthly File-----------------> 09 - Swiggy December-2021

Hi @Anand_Designer

if file name changes dynamically with respect to month
then in If condition you can use like this

item.tostring.trim.contains(“Swiggy”+" "+DateTime.Now.ToString(“MMMM”))

Thanks

Hi @Anand_Designer

Try this expression

Directory.GetFiles("Your folderpath","Swiggy MPR Monthly File-----------------"+DateTime.Now.ToString("dd")+" - Swiggy "+DateTime.Now.ToString("MMMM-yyyy"))

Alternative based on the workflow

item.Tostring.Trim.Contains(“Swiggy ”+Now.ToString(“MMMM”))

Regards
Gokul

How to add -2 months this syntax ?

Hi @Anand_Designer

Try this expression

DateTime.Now.AddMonth(-2).Tostring("MMMM")

Regards
Gokul

HI @Anand_Designer

item.Tostring.Trim.Contains(“Swiggy ”+Now.AddMonth(-2).ToString(“MMMM”))

Regards
Gokul

1 Like

we can setup a regex pattern like:
grafik

And if a more detail date check is needed we can rely to the groups:
grafik
for further evaluations

As an alternate:
If pattern is reliable then we can generate the string for the month of interest and use it for the file retrieval

1 Like

Thank you for given solution . its working fine…

Great @Anand_Designer

Happy Automation

Regards
Gokul

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