How could get all excel files in a folder except one excel with special name

dear all,

in one folder, for example there are three excel files, named 1.xlsx , 2.xlsx and master.xlsx.

i used directory.getfiles(path, “*.xlsx”) to to get a string but i dont not want contains the master.xlsx just 1.xlsx and 2.xlsx , how could i achieve this function?

anybody could give a guide ?

thanks a lot in advance

@Chris-Yiwei even though you get all those files you can filter by using if condition inside the for each loop,say for example as you said there are three files out of that you want only two,so inside the for each loop you can give if condition like item which contains master if it finds it went to then if not else,so to the else condition other two files will come.have a try this

@Chris-Yiwei

Try this expression:

directory.getfiles(path, “?.xlsx”)

Just replace wild card star “*” with question mark ? And then try.

1 Like

i used this directory.getfiles() it will collect all the xlsx files, but i want to excluse one special excel file

@Chris-Yiwei

Just try the above expression and it will skip master file and will give remaining files.

i used directory.getfiles(path, “master.xlsx”) the output file is only master.xlsx but i do not need master.xlsx just need 1.xlsx , 2.xlsx

1 Like

@Chris-Yiwei

I said try this one:

directory.getfiles(path, “?.xlsx”)

i print the result , it is empty directory.getfiles(path, “?.xlsx”)

Hi
Kindly folllow the below steps that could help you resolve this
—use as assign activity like this
Out_Filepatharray = Directory.GetFiles(“yourfolderpath”,”*.xlsx”).Where(name => !name.EndsWith(“Master.xlsx”))

Or by this mean as well @Chris-Yiwei
Out_Filepatharray = Directory.GetFiles(“yourfolderpath”,”*.xlsx”)

Out_filesToExclude = Directory.GetFiles(“yourfolderpath",”*.xlsx");

Out_wantedFiles = Filepatharray.Except(Out_filesToExclude);

Cheers @Chris-Yiwei

@Chris-Yiwei
Were we able to get the correct files
Cheers

what is the type of variable Out_Filepatharray , Out_filesToExclude and Out_wantedFiles.
i use this approache , compile error

All should be string array

Do we need to Assign 3 activity??

Hi
Welcome to uipath community
Kindly come again
I didn’t get that
Cheers @ViswanathanAM

1 Like

Thank you for your warm welcome !!

do i need to create 3 assign activity??

Out_Filepatharray = Directory.GetFiles(“yourfolderpath”,”*.xlsx”)

Out_filesToExclude = Directory.GetFiles(“yourfolderpath",”*.xlsx");

Out_wantedFiles = Filepatharray.Except(Out_filesToExclude);

i tried as per the above but i am getting error message !!

could you pelase share your xmal. file. so that i can easily verify with your assistance :slight_smile:

Hi All,

I have made small workflow in that if I print the value. Its printing without the data.

please find the attached screenCapture shot for your reference.

Capture3