Hello - i have the following code when instructing to string all names of files in folder. Since the characters circled in the below snip change each time I run the BOT I would like to be able to update those characters ONLY with a line that is in my notebook. Any idea how I can do this? I tried creating this entire path, including “string.format…” as a reference to my notebook but the BOT will not use it. Hopefully that made sense.
Hi,
String.Format works as the following, for example.
So, can you try to replace part of string which you want to replace with {0} , {1} or {2}…etc., then add string which you want to replace with as arguments after it?
Regards,
Hi @audra.swope
Fallow the steps below. If I helped you, please mark it as solved.
You can dynamically change characters in your code by using variations within string.format in UiPath. Ideally, you would define these variables outside of the editor, and then insert them directly into the path, so that the BOT automatically updates them with the correct values on each run.
For example:
string.format(“G:\Alexander\Qualifying Assets\Real Estate\WHOLLY OWNED PROPERTIES\Distributions_Contributions\AI{0}{1} - {2}\Calcs{3}.xlsx”, Year, Month, Filename, CurrentRow.ByField(“filename”))
In this case, Year, Month, and Filename could be variables pulled from your notebook or another part of the automation. This ensures that these parts of the path are dynamic.
As this is path instead of string.format…you can use
Path.Combine("C:\abc\folder1",variable1,variable2,"folder5\filename.xlsx")
cheers
Sorry it took me so long to mark this as my solution, but this was extremely helpful and solved my problem. Thank you!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

