How to get specific files from the folder

Hello team,

I need to get some specific files from folder

  1. Folder path like this -\10:20:10\track\survil file\comodity\MCx
  2. Inside - \Mcx\current month folder (Dec2023)\day folder \ files

These are my file name for exin below image

Now we have to check files are available or not if files are not available den email to user if the file are available den move to destination path

I have done with for each file in folder it’s working but I have to create extra folder to move files and then I’m checking file available in that folder so this logic not looking good I need in one step check file available or not

Thanks

@suraj_gaikwad

Use path exists to check the file or folder exists

Cheers

Yes, done that and it’s true

@Anil_G

@suraj_gaikwad

So what is the issue now?

Cheers

Files are available but it’s going in else condition

@Anil_G

@suraj_gaikwad

Did you try to log and check if it returned any files

Check the formula

Cheers

This what I used in if

@Anil_G

@suraj_gaikwad

You are comparing locations there and i dont thing two locations are same

You need not have secon loop instead use this

Arrfiles.Any(function(x) Path.GetFileName(x).ToUpper.Contains(currentFile.Name.ToUpper))

Use this in if with out loop on arefiles …if file present it would go to then side

Cheers

Stil it’s going in else condition

@Anil_G

@suraj_gaikwad

Can you please tell what is there in arrfiles check the value of it

Also can you log only name instead of fullname and check

I hope your array contains the filepaths and we are extracting only name which is same as currentfile name…please confirm the same

Better use two log messages one with currentfile.Name and other with String.Join(",",arrfiles.Select(function(x) Path.GetFileName(x)))

This will show if names are matching or not at all

Cheers

In arrayfiles I provide file names

@Anil_G

@suraj_gaikwad

Please check as above

Cheers

Log messages output coming like this

@Anil_G

@suraj_gaikwad

Okay so you dont have extension

Change the formula like this

Arrfiles.Any(function(x) currentFile.Name.ToUpper.Contains(Path.GetFileName(x).ToUpper))

Cheers

Still it’s going else part :smiling_face_with_tear:

@Anil_G

@suraj_gaikwad

Add a trim and check…on both sides

Cheers

Already try that
@Anil_G

@suraj_gaikwad

Just to check do a replace of _ on both sides

Also log both of them separately

Cheers

Issue solve but I need directly go in true condition once the file match .

If the all files got den it’s in true condition otherwise in else condition

@Anil_G

@suraj_gaikwad

any works with atleast one match

or use where with .count>0

cheers