Find Specific type of File in Folder in UiPath

Hi Welcome to another short post.

In this post we will see how we can find a specific type of files from a folder which contains multiple file types.

So I have this folder, as you can see it contains different types of files, like Excel, PDF and word documents but I want to get only the PDF files from this folder. 

Launch UiPath. Create a blank project, and drag a Assign Activity and Create a Variable Called FolderPath and assign it to the Base Folder Path.

Now we want to iterate through each file and check if it is a PDF file or not, and We will show the File path in a Message box, in case of PDF file.

For that lets drag and Drop the For Each Activity and here we will use Directory.GetFiles(folderPath,”*.pdf”,)

So this will only give us the PDF file you can put any other extension you want to search other type of file

Now in the Body we will add a Message Box and type item.toString.

Now we are ready to run this process and see its Output

You will get the full path PDF Files one by one in message box.

If you want to search inside the subfolder of parent folder all you need to do is to another parameter to Directory.GetFiles which is System.IO.SearchOption.AllDirectories and this will search in all the sub folders for the provided extension file types.

So this is how you get any specific file from a Folder in UiPath, The text version of this video is also available on our website codehunters.in. Where you can download the source code of this video.

Hope this helps and I will see you in the next post. Till then Code with Confidence.

Download Source Code

you're currently offline