Text file dynamic creation

Hi everyone,
for every execution of my process, I have to generate a dynamic text file titled like this:

“Date” + “time of execution” + Variable + Variable + “String” + Variable + “String”.txt.
Could anyone tell me how to write it, please? I have some problems with " " and have warnings.

Thank you all.



use append line activity and type the expression like below!

“Now.ToString(“dd-MM-yyyy”) + “time of execution” + Variable + Variable + “String” + Variable + “String.txt”


I’m sorry, I wrote the wrong title. It has to be: ““String” + Version.txt”. But I have a warning about an expected end of the expression.
I don’t think it’s the correct activity, because I don’t want to write into the file text for now, but give it a dynamic name for each execution and also I have to save it in a folder, while here I have to select a specific file text path.
Thank you.

Hi @martina.cavalieri

Could you share me the screen shot of your process ?


we escape it with double quotes:

within the visual output we got informed about the escaped character with \ but \ will not be part of the string. It is just a visual representation

But keep in mind a quote is not valid within a filename

I’m sorry, but I don’t understand how to use double quote for the text file title and what activity to choose…


same acitvity where you had implemented.

But be a little more specific:

file name: does not allow " within the name
text file title sounds like content of a text file

Please share it with us. Thanks for support

Sorry, I don’t understand.
My process consist of a web browsing session where I take some information and I check if they are on the screen. At the end I have to create a text file where I put the results. For each time I run the process I need that a new text file is created and save in a specific folder. My questions are:

  1. what activity do I have to choose for this?;
  2. how can I write a dynamic title?

I can share with you some screenshot, but I don’t know if it is useful for you.


The activity I need has to be at the end.



The text file title has to be like this: “(Process name)” + variable.txt.
I’m sorry for the misunderstandings, but I panicked…

we assume that here on yellow mark you would like to write a string on the file, containing quotes within the middle, right?


so give a try on
Now.ToString("dd-MM-yyyy") + " time of execution " + "other Text and ""Text within quotes"" End of text.txt"

And you will get:
05-10-2021 time of execution other Text and “Text within quotes” End of text.txt

with the double quotes we produced: “Text within quotes”

In some cases we do also use String Format method

In case of there are some doubts you can do following:

Send us a sample line along with the samples for used Variables like
I am a sample text "status" <Variable1> some other end text
Variable1 = DRAFT

and result should would look like:
I am a sample text “status” DRAFT some other end text

Hi @martina.cavalieri

You need to change the file path of the append line like below

“Yourpath/”+“your process name”+“/”+yourvariablename+“.txt”


Expected end of expression just means you have your double quotes wrong.

“Date” + “time of execution” + Variable + Variable + “String” + Variable + “String”.txt.

“String”.txt is wrong. You have .txt outside the double quotes so it is processed as an expression, not a value. It needs to be “String.txt”

“Date” is a string containing the word Date. Are you trying to have it be the actual current date? Something like…

Now.ToString(“MMddyyyy hhmmss”) + Var + Var + “String” + Var + “String.txt”

I’ll try and let you know as soon as possible.

Thank you all so much, you are great!


Hi everyone,

as I promised, here you are what I’ve done.

“Assign” activity for the file path:

fileName = “O:\RBT_PuliziaPortafoglioSvincoliMartina\Esecuzioni”+ " V167_Ciclo_Aliquote_Plafonamento_Consultazione " + Version+“.txt”.

“Write text file”:

DateTime.Now.ToString(“MM/dd/yyyy”)+ " “+StartTime.ToString(“HH:mm:ss”)+” “+ServerName+” “+Version+” "+ " Nexus “+” “+Esito+” Ciclo 167 - Aliquote plafonamento consultazione "+vbCrLf+ "Test result: "+vbCrLf+NomeUtente+vbCrLf+ "Tabella visualizzata: "+Esito+vbCrLf+ "Fine elaborazione: "+DateTime.Now.ToString(“MM/dd/yyyy”)+ " "+EndTime.ToString(“HH:mm:ss”)

Write to file name:

Now I have two problems:

  1. This is the folder where I want the text file to be saved:


But UIPath saved it here:


  1. I want that a new text file is generated after each run, but it always rewrite the same.

Could any of you help me, please?


fileName = "O:\RBT_PuliziaPortafoglioSvincoliMartina\Esecuzioni\V167_Ciclo_Aliquote_Plafonamento_Consultazione " + Version+".txt"

Just check the closing \ for the different directories

Hi @martina.cavalieri

Is the version from the path is value or Variable!

If is value then the path expression would be like below

“O:\RBT_PuliziaPortafoglioSvincoliMartina\Esecuzioni\”+ " V167_Ciclo_Aliquote_Plafonamento_Consultazione"+"\" + "Version.txt".

Or if its variable then expression like below

“O:\RBT_PuliziaPortafoglioSvincoliMartina\Esecuzioni\”+ " V167_Ciclo_Aliquote_Plafonamento_Consultazione"+"\" +Version+".txt".


@ppr You’re right. The correct path is: “O:\RBT_PuliziaPortafoglioSvincoliMartina\Esecuzioni\V167_Ciclo_Aliquote_Plafonamento_Consultazione " + Version+”.txt".

But I ran it twice and didn’t generate two text files: it rewrote the same. How can I solve?


have a check if instead of Version a now.toString(“yyyyMMdd-HHmmss”) will better serve, as it is versioning with a date/time info

@ppr Version is a variable conteining a string with the number of the application. It is taken from the screen.

You can also combine two approaches for the option to run the bot multiple times with the same version info