How find files in the folder?

Hi,
i m having a list… it has a some items in it.
ex: L1 = 123 ,
8888
9999
now find the files with these name in a folder.. .After finding save it to some other folder(folder xyz)
ex: folder A - which has files as below
123-INI.pdf
8888-SEIT.pdf

Thank you
Seem

Hi @Seem

Use Directory.GetFilenamewithoutextension and use for each item and check it by using path exists

Thanks
Ashwin.S

@Seem Hai… u need to use create folder activity and check using path exist activity choose folder in it, then use path.getfilenamewithextension
And copy the file path then create one more folder& copy the path there

@Seem
Setup following variables (Feel free to use different names)

A flow could look like this:

With Directory.GetFiles(YourFilePath) you get returned a String Array of files from a particular folder

I a for each loop you are iterating over all filenames. A temporary variable is holding the filename without path: Path.GetFileName(item)

In an If Else FileParts.Any(Function (x) tmpFileName.contains(x)) checks if the filename of current iteration contains any item from the list/Array of File Parts in its filename. With the result of this check it goes to the file moving branch or not

Let us know your feedback

Hi @ppr,
@AshwinS2
@Nandhuba

actually i am having a list . AList
this list items i have to check in the folder i used (FileList) , i did it as below.

Now i have to save the files to the folder i created in the if condition.

how to do?

also - this is not working-==FileList.Contains(item.ToString)

@Seem
looking at your implementation it is reasonable that some parts will have issues:

  • Before Creating the Directory do allways a check if this Directory is missing or already exisiting

Once iterating over the FilePartList (123,8888,…) you will not retrieve the information on the fullfilename and also the contains has another meaning as it would work on full Name matching. So Info of the filename that is to move is not retrieved / known.

Have a look on my Description above and see how it is handled there

1 Like

@ppr
i could not get,
can u please help me how to do it…?

@Seem
Have a look on this Starter Demo XAML: Seem.xaml (7.9 KB)

1 Like

@Seem
FileParts.Any(Function (x) tmpFileName.contains(x))

the any method returns true or false if for any element (one ore more) the statement was fullfilled
In this case it looks for each item in FileParts if it is contained in the filename
https://www.tutorialsteacher.com/linq/linq-quantifier-operators

this linq statement can as well implemented with the essential activites. It would look like this:

Demo Xaml here: Seem2.xaml (9.2 KB)

1 Like

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