By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
RPABOTS.WORLD
  • RPA & Bot Automation
  • Agentic AI & AI Automation
  • AI Agents & Frameworks
  • uipath tutorial
  • UiPath
  • AI Agent Governance
Subscribe
  • Agentic AI
    • AI Agents & Frameworks
    • Agent Memory & RAG
    • Multi-Agent Systems
    • UiPath Agentic Automation
  • RPA
    • Topics
      • UiPath
        • uipath tutorial
  • Tools & Platforms
    • AI Builder
    • Robot Framework
  • Use Cases
  • Learn
    • UiPath
      • uipath certification
      • uipath interview questions
Reading: 20 +Essential Uipath Tips and Tricks for File and Folders
RPABOTS.WORLDRPABOTS.WORLD
Font ResizerAa
  • Agentic AI
  • RPA
  • Tools & Platforms
  • Use Cases
  • Learn
Search
  • Agentic AI
    • AI Agents & Frameworks
    • Agent Memory & RAG
    • Multi-Agent Systems
    • UiPath Agentic Automation
  • RPA
    • Topics
  • Tools & Platforms
    • AI Builder
    • Robot Framework
  • Use Cases
  • Learn
    • UiPath

Must Read

Databricks Agent Bricks: Enterprise AI Agent Platform Guide 2

Databricks Agent Bricks: Enterprise AI Agent Platform Guide

Tungsten Automation (Formerly Kofax): How the IDP Pioneer Is Betting on Agentic AI to Reinvent Enterprise Document Automation — Complete Guide for Agentic AI Architects (2026)

GitHub Universe 2026: Copilot Fusion, the Agent-First SDLC, and What It Means for Agentic AI Architects

Gartner Hype Cycle for Agentic AI 2026: The Complete Guide

Traversal AI: The $1B AI SRE Unicorn Reshaping How Enterprises Handle Production Incidents — Complete Guide for Agentic AI Architects (2026)

Follow US
RPABOTS.WORLD > Blog > Topics > UiPath > uipath tutorial > 20 +Essential Uipath Tips and Tricks for File and Folders
uipath tutorial

20 +Essential Uipath Tips and Tricks for File and Folders

Satish Prasad
By
Satish Prasad
4 years ago
uipath tutorial
1 Comment
Share
13 Min Read
SHARE

In our day to day automation task, we often need to perform one of below activities and we google them on a daily basis to find the perfect working example. In this blog post, RPABOTSWORLD Team has curated the list of such File Handling Operation for your quick reference as Uipath Tips and Tricks for File and Folders. You can bookmark this page to refer same in your next Uipath Automation.

Contents
  • #1 How to get list of files and count of files in Directory in UiPath
  • #2 How to search particular file in folder and copy that file
  • #3 How to search a particular keyword in the file from the folder and copy/move that file
  • #4 How to get Current working Directory if you want to ensure file location ?
  • #5 How to get File Name & File Name without extension ?
  • #6 How to get files in the order they are in the folder (i.e Create Time) ?
  • #7 How to Extract Files list from Directory /Folder with specific Keyword from file name ?
  • #8 How to get Get files with multiple extensions from folder location ?
  • #9 How to get Get files excluding a certain file extension ?
  • #10 How to create folder with today Date on run time?
  • #11 Create a file with the current date and time in the name
  • #12 How to list names of Sub folders inside Folder using Uipath
  • #13 How to get the the latest Downloaded file from download location.
  • #14 How to Iterate through files in multiple sub folders to get all files
  • #15 How to delete multiple files from folder in UiPath
  • #16 How To Delete Multiple Files – In UiPath based on creation date
  • #17 How to find duplicates files form folder in UiPath
  • #18 How to Zip & Unzip files
  • #19 How to sort and get list of files of based on Size limit
  • #20 How to Calculate Size of a particular file

Lets get started !

#1 How to get list of files and count of files in Directory in UiPath

If you have a specific folder and you want to count files from that specific folder in UiPath. You can use below code snippet

  • Directory.GetFiles(“”) 
  • Directory.GetDirectories(“”, “*”, SearchOption.AllDirectories).Count()

#2 How to search particular file in folder and copy that file

If you want to search a particular file in a folder by using filename(which may vary every time bypassing variable) and copy that file for further process. You can do that using below Syntax.

  • requiredFile[] = Directory.GetFiles(“FolderPath”,varFile+”*”)
  • Then use Copy File activity and pass like requiredFile(0) as file name

#3 How to search a particular keyword in the file from the folder and copy/move that file

Many times we need to search for a file which contains specific keywords… let’s take an example of Invoice No as a keyword ( ‘INV20200101118’ ) to be searched inside the folder of .xlsx files

You can get the result using below –

  • arr_filepath = Directory.GetFiles(“yourfolderpath”,”*.xlsx”)
  • Next use for each activity to go over the array variable arr_filepath
  • item.ToString.ToUpper.Contains(“<>”) to check the file using the if activity
  • Finally, perform the action as you wish with the given file-like a move or copy

#4 How to get Current working Directory if you want to ensure file location ?

To get the current working directory use UiPath.Core.Activities.GetEnvironmentVariable, The value of the selected environment variable will result in output.

  • Get Environment Variable Activity
  • Type – “CurrentDirectory” in it

Retrieves all environment variable names and their values from the current process.

More Read

UiPath Code Review Checklist
UiPath Code Review Checklist – To Perform Effective RPA Code Reviews
UiPath Coded Automation: Revolutionizing the Future of Robotic Process Automation (RPA) 4
UiPath Coded Automation: Revolutionizing the Future of Robotic Process Automation (RPA)
UiPath Picture in Picture (Experimental)
UiPath Picture in Picture 20.4 (Experimental) Hands-on

#5 How to get File Name & File Name without extension ?

Many time we need to remove the file extension or we need to get the file name from long network drive, You can easily perform such task using the below code snippet.

Path.GetFileName(fullPath) and Path.GetFileNameWithoutExtension(fullPath)
Both will return strings and you don’t need to create additional variables.

#6 How to get files in the order they are in the folder (i.e Create Time) ?

There are scenarios when you need to process the files form directory in the sequence they are written into the folder or you to list out the files name from the folder in the sequence they are created. In both the cases, you will be able to get the list of file name using below syntax.

Directory.GetFiles(“folderPath”).OrderByDescending(Function(x) x.LastWriteTime).ToArray

Or You can use assign activity

Out_Filepatharray = Directory.GetFiles(“YourFolderPath”).OrderByDescending(Function(d) New FileInfo(d).CreationTime)

#7 How to Extract Files list from Directory /Folder with specific Keyword from file name ?

Many times we need to process the files with specific prefix for example lets say we are looking for only Invoice Pdfs from the list of many files in the folder. One thing they have common in the file name is keyword called ‘Invoice’ , in such case you can get the list of all the invoices using below code snippet.

pdfInvoiceFiles [] = Directory.GetFiles("FolderPath","Invoice*")

#8 How to get Get files with multiple extensions from folder location ?

Some automation requires to get only a few specific types of files to be processed, so you need to filter out the required file extension from the list of files of the various extension. Say for example you need to filter out the image files of only types (.png|.jpeg|.jpg|.gif) in those case you can use below code snippet to get required file types.

Directory.GetFiles("C:\path", "*.*", SearchOption.AllDirectories) .Where(file => new string[] { ".jpg", ".gif", ".png" } .Contains(Path.GetExtension(file))) .ToList();

#9 How to get Get files excluding a certain file extension ?

This is a similar situation where you need to work on all types of the file except one file extension, In those cases, you can use below code to Get files excluding a certain file extension.

Directory.GetFiles("folder_path").Where(Function(n) path.GetExtension(n) <>".zip").ToArray

#10 How to create folder with today Date on run time?

In many workflows we need to create daily folders before we start downloading the Pdf or any other reports, This often requires you to create a folder in a designated location with today date in different formats like ‘2020-02-18′ or ’20-02-2020’ so you can use “formate-string” with Date Time to create folders. for example

"C:\Users\Windows\Downloads\”+Datetime.today.tostring(“yyyy-MM-dd”)

#11 Create a file with the current date and time in the name

Most of the time when you download some report you need to save the downloaded report as filename + date +time, in those case you can get the current date using ‘System.DateTime.Now.ToString()’ and the combine this with the path + file +datetime to save as in required name format.

You can use below code to get the required format.

folderpath= path.GetFullPath(“folder_location”.ToString)

path.Combine(folderpath.ToString,“file_name”+system.DateTime.Now.ToString(“dd.MM.yy HH;mm;ss”)+".pdf")

#12 How to list names of Sub folders inside Folder using Uipath

Some times we need to count the subfolders or check folder inside the folder to see they are there before we perform the further operation. To check the list of subfolders inside the folder we can use below code block using Directory.GetDirectories to retrieve all the subfolders and then Path.GetFileName to get the name of each subfolder.

Directory.GetDirectories(“yourDirPath”).[Select](Function(d) New DirectoryInfo(d).Name).ToList()

Or alternatively you can use below to write the list of all subfolders.

string.Join(Environment.NewLine, Directory.GetDirectories(“yourDirPath”).[Select](Function(d) New DirectoryInfo(d).Name).ToList())

#13 How to get the the latest Downloaded file from download location.

Many time we work with downloading file & report and once downloaded we need to read the same file for further operation… You can do that using multiple option but as explained above Function can be used with Directory.GetFiles() with required parameters to perform the task.

String.Join(“”, Directory.GetFiles(our_FolderPath,”*”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

#14 How to Iterate through files in multiple sub folders to get all files

We often need to get all the files from directory and even if they are in the sub folder of given directory in those cases you can use below code snippet to get the list of all the files even if they are at the nth level of nested file location.Check below statement, it will gives output as file paths as array.

Directory.GetFiles(“Your main directory path”,"*",searchOption.AllDirectories)

#15 How to delete multiple files from folder in UiPath

We often need to delete files from folder location based on some criteria or simply all the files in the folder location.

if you wish to delete all the files from given folder location you can use.

Array.ForEach(Directory.GetFiles(@”folder_location”), File.Delete)

Make sure to include if activity to ensure there are files before you delete them Directory.GetFiles(“”).Length > 0

You in case you need to delete only .xlsx or .pdf extension files

Array.ForEach(Directory.GetFiles(In_FileDirectoryPath,"*"+In_dotExtension),File.Delete)

if you are not comfortable in writing one-liner code you can use Directory.GetFiles(In_FileDirectoryPath,”*”+In_dotExtension) to get list of all the files and then use UiPath.Core.Activities.Delete activity inside loop to perform same task.

#16 How To Delete Multiple Files – In UiPath based on creation date

In many cases we need to do housekeeping & delete files which are not required any more need to be deleted. This is specifically important when you are working on file on Network Share Drive.

To delete multiple unwanted file from location you need to perform following Tasks

  1. Get the list of file path using Directory.GetFiles(InputFolderPath)
  2. Loop over list of file to get their modification time IO.File.GetLastWriteTime(item.ToString)
  3. Compare modification time to Current Date with no of days so that you can filter old files if you want to keep todays as well as yesterdays modified file’s then pass NoOfDays as -1 so that DateDiff(DateInterval.Day,convert.ToDateTime(now.ToString),FileLastModifiedDateTime)<NoOfDays
  4. Finally use the UiPath.Core.Activities.Delete to delete the file.

#17 How to find duplicates files form folder in UiPath

Deleting duplicate files in a folder, requires you two step process , the first step is more important when you need to find the list of duplicate files. Deciding file is duplicate depends on use-case for some if they are having same name in other case they have some content with different names. How ever the steps will remain same.

Directory.GetFiles("folder_location","<em>.</em>",SearchOption.AllDirectories).GroupBy(Function(x) x).Where(Function(x) x.Count &gt; 1).Select(Function(x) x.Key)

once you get the list of files you can perform further operation using loop over duplicate files.

#18 How to Zip & Unzip files

There are multiple options available for Zip & Unzip files in Uipath.

  1. You can use PowerShell Invoke Method to perform the task
  2. You can use Zip and UnZip from UiPath Go

Zip Activity

It is a popular archive format widely using in Internet. ZIP files are data containers. They store one or several files and folders in the compressed form as a single file. Password is optional. It compresses in “zip” and “rar” format.

Unzip Activity

It is the act of extracting the files from a zipped single file (with password) to a specific folder.

#19 How to sort and get list of files of based on Size limit

Limitation is every where ! Some time you are not allowed to upload size which is greater than allowed limit or some time with restriction of extension types …

by using below code snippet you will be able to sort files /list if their size is with in allowed limit.

files = Directory.GetFiles(dir, filePattern).Where(Function(f) New FileInfo(f).Length <= sizeLimit).ToArray

You can also sort them in order of their file size as below

files = Directory.GetFiles(dir, filePattern).Where(Function(f) New FileInfo(f).Length <= sizeLimit).OrderBy(Function(f) New FileInfo(f).Length ).ToArray

#20 How to Calculate Size of a particular file

You can calculate the file size using below code snippet in uipath.

"Size in mb: " +Math.Round( ((dirInfo.EnumerateFiles("*", SearchOption.AllDirectories).Sum(Function(fi) fi.Length) / 1024F) / 1024F),1).ToString

Happy Automation !

Please feel free to suggest or comment in case you need additional details to be added here.

Share This Article
Facebook Print
BySatish Prasad
Follow:
Satish Prasad An NIT Kurukshetra alumnus and Intelligent Automation Architect, Satish brings 15+ years of battle-tested experience deploying over 100 production bots across Investment Banking and Logistics. Today, he bridges the gap between Data Analytics and the frontier of Agentic AI, building autonomous agents that transform complex business logic into intelligent automation. Catch his latest insights on the evolution of tech vibes and digital autonomy.
Previous Article The Complete Beginner’s Guide to BluePrism Certification 5 The Complete Beginner’s Guide to BluePrism Certification
Next Article Microsoft Power Automate Automate Using Impressive Microsoft Power Automate 2021
1 Comment 1 Comment
  • Meong says:
    12/04/2021 at 3:24 am

    amazing, thx tips and trick, helpfull for newbie like me 😀

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You Might also Like

Entities in the Data Service UiPath

UiPath Data Service Entities | Step by Step Guide | 20.10

Working with UiPath Data Service Entities | Persistence Data storage | Preview in UiPath 20.08…

By
Satish Prasad
13 Min Read
Building a LangGraph Agent on UiPath

How to Build and Deploy a LangGraph Agent on UiPath: The Complete Coded Agent Tutorial (2026)

In the first four months of 2025, U.S. Customs and Border Protection completed 200 import…

By
Satish Prasad
26 Min Read
Introducing UiPath AI Fabric

UiPath AI Fabric Tutorial | Build Your ML Based RPA Project

UiPath AI Fabric Hands-On Exercise & Tutorial 2020 (Complete Working Example with Different ML Models)…

By
Satish Prasad
16 Min Read

ServiceNow and UiPath Communication Mining Example: Enhancing ITSM Efficiency

Problem Statement: ServiceNow Auto Ticket Triaging ServiceNow is a popular IT service management (ITSM) platform…

By
Satish Prasad
20 Min Read
Guide to Using Different UiPath OCR Engines

Comprehensive Different UiPath OCR Engines | Working Example

Step by Step Guide to using OCR Engines with UiPath

By
Satish Prasad
22 Min Read
SAP Automation Using UiPath | Step-by-Step 7

SAP Automation Using UiPath | Step-by-Step

(Step by step guide to learn SAP automation with UiPath and SAP GUI) Share on…

By
Satish Prasad
14 Min Read
RPABOTS.WORLDRPABOTS.WORLD
Follow US
  • About RPABOTS.WORLD
  • Write For Us
  • Contact-us
  • Privacy Policy
  • Cookie Policy
  • Disclosure