How to Create same dated folder with specific numbers in main folder as per number of times BOT execution happened


I want to create Run wise folder in my main folder as per BOT execution happened.
Like If BOT run 3 times in a day 3 different folders has been generated.
For Ex. 07/16/2020 - Run1 (If Bot run for first time)
07/16/2020 - Run2 (If Bot run for second time)
07/16/2020 - Run3 (If Bot run for third time)

The main purpose of this is I am storing my transaction completion data into today’s folder. but my worry is if user run the BOT again on same date then previous data will be affected.


In the above screenshot two sub-folders has been created as per transaction happened for first run. but if user run the BOT second time this folders will affected.
Sample automation which I created has been attached for reference.

Finally I want to achieve the target for folder creation as per below.

Main.xaml (65.4 KB)

Hi @nilesh.mahajan,

The easy way is to able to count the number of folders for a specific date like 07-16-2020

If this folder structure make sense to you…then read on.

Assign activity
To = RunNumber
Value = System.IO.Directory.GetDirectories(UserPath).Count


  1. UserPath is String variable containing value “C:\UiPath\1st Trial Project with Baan\07-16-2020”
  2. RunNumber is Int32 variable

This will count how many folders or runs in a specific date folder. After each run, you only need to use activity Move File to rename the folder “236” to RunDate + " - Run" + (RunNumber).ToString

Note: RunDate is String variable containing value “07-16-2020” for example.