Hi,
I am reading data from a worksheet and writing the data into a new file. My question is how can I change my output file name every time I run the sequence? how can I keep the old output file and create a new one when I run the sequence again?
Thank you.
Does your output file have different requirements? Like is it a daily run and you need to make the date?
If so you could do something like âDaily Runâ+now.tostring or something in your output variable.
You can save you dynamic file name in a variable and yes you can use this
"FileName"+DateTime.Now.ToString+".xlsx"
Thanks,
Prankur
Itâs a weekly run and I would like to name it based on the date. (results-11-28-2018)
Thanks
Hi Prankur,
I am new to UiPath and I tried to define the dynamic file name in a variable but itâs not working for me.
Can you give me more details in how I can define the variable?
Thank you,
Ahmed
What variables did you try? and what message is it giving you?
I tried a string variable and in the default box I typed in âfilenameâ+DateTime.Now.ToString+â.xlsxâ
I didnât get an error message it just kept overriding the same file.
I am not sure if I am doing it the right way.
Thanks
do you have a copy of your xaml file?
Main.xaml (9.3 KB)
Thanks
@alotfy, ShilpiJâs workflow will probably work for you, but I think we can leave the time out of the filename and only put the date like so: âresultsâ+Now.ToString(âyyyyMMddâ)+â.xlsxâ
Another thing Iâd like to mention is that it might look to you as if your file is still overwriting the previous file even though you run this workflow. The reason is that todayâs date doesnât change after you run it, but donât worry because âNowâ will change tomorrow. If you want to double check if it really works, you can run it again tomorrow. If you canât wait until tomorrow, you can try âresultsâ+Now.AddDays(1).ToString(âyyyyMMddâ)+â.xlsxâ the next time you run and that will give you tomorrowâs date.
Thank you ShilpiJ!! it worked. I really appreciate your help.
When i run ShilpiJâs workflow it worked but i got a strange number at the end of the file name (results11292018 102344.xlsx) and every time i run it creates a new file which is good. When i tried âresultsâ+Now.ToString(âyyyyMMddâ)+â.xlsxâ i didnât get that strange number at the end of the file name but as you said it overwrites the file if i run it on the same day more than once, which is okay. Thank you for your help pathLessTaken!
@alotfy That number is current date & time
Ohh i knew about the date but didnât know about the time! that makes sense! thanks again!