Uniquely rename file

I have one sample excel file. I’m coping that file to new location with unique name .for 1st record i’m using write range & for remaining record i’m using append range to add results. Every time when i run process i want to use that sample file template to store the results in it. So my problem is how can i rename that file with unique name. Currently i’m using date time but that process has multiple records.for every record time changes then how can i use that file created at 1st record time.
@Sudharsan_Ka @supermanPunch @Anil_G

Hey @pravin_bindage,
Instead of date time you can just use just date now.tostring(“dd/MM/yyyy”) so for that date you can use template. Along with that can give the count to make it unique the number of times you ran per day


HI @pravin_bindage

Assign a New integer value

Before creating the file
Assign CountFile=Countfile+1
WHen creating the file you can use


So If you use Filename_07032023_1 it will get you the first file that is created


If i run same process again same day with different records then it overwrites that earlier file?

If you run the process multiple time try this

Give the file name like this
FIlename_Date_ +(Directory.GetFiles(FolderPath,“FileName_date*.extension”).Count+1).Tostring.extension

Then it will be updated based on the file count in the folder so the file will not be overwrited



You can store the time and use it as the file name for whole of the process

At the start of the process use a variable and store "FileName_" + Now.ToString("MMddyyyyhhmmss") + ".xlsx" say this is stored in str variable

Then in whole of the process for every transaction we can use the same name and as it contains timestamp…for everyrun it would be unique as well

Hope this helps


In which state of RE Framework should i store it?


You can store it in initialization state inside the first run if condition…

So that it can be unique for the run and can be used across the transactions


i checked add headers option but still headers not adding is there anything i’m missing?


In the main datatable do you have headers?

If yes then in the required write range did you check the add headers option…

Please check the same…


Yes my sample excel have headers which i use as a template


If your template already has headers…then I see you are writing from A1…instead write it from A2…as the first row already has headers in it


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.