Open File that contains the specific name

Hi all,

I’m new to UiPath and I’ve been trying to do a loop whereby if the file name contains the client name, the robot will export the file to pdf, else it will show a message box. What should I type in the word application scope if I want to open the file that contains the client name?

Thanks

HI @lq_c

In the Assign activity

FileDir = Directory.GetFiles(Environment.CurrentDirectory+"\WordPdf\","*.pdf")

FileDir  | Variable type -> Array(String)

Here -> Environment.CurrentDirector is the folder path

"C:\Users\Dell\Documents\UiPath\Test"

You can with the extension based on needs "pdf"

In the If activity

Path.GetFileNameWithoutExtension(currentItem).Contains(selectedFiles)

This will get only the file name -> Path.GetFileNameWithoutExtension(currentItem)

Check out this XAML file

DirectoryFiles.xaml (8.3 KB)

Regards
gokul

Hi,

It might be letter-case matter. If you already know client name, the following condition works.

System.IO.Path.GetFileNameWithoutExtension(file.ToString).ToLower.Contains(yourClientName.ToLower)

If you need to get the client name from client code, can you try to create dictionary in advance (Let’s say dict), then try the following condition?

System.IO.Path.GetFileNameWithoutExtension(file.ToString).ToLower.Contains(dict(selectedClintCode).ToLower)

Regards,