Change of file name in type into function

I have a folder with file names in a sequence like schedule 1, schedule 2. In my program i’M using type into function where i type the file name . What must I add that the file name changes from schedule1 to schedule2 automatically when the program runs for the second time.
from this:“C:\Private\New folder\SKM-RE_Scheduling-20180521-2.xlsx”
to this: “C:\Private\New folder\SKM-RE_Scheduling-20180521-3.xlsx”


It sounds like you want to check if the file already exists then use an incremental filename to create a new one.

You can probably do this in a Retry Scope with a counter
Something like this:

Retry Scope with "Is True" activity in condition spot //with condition System.IO.File.Exists(filepath)
   Assign filepath //concatenate counter if it's > 1
   Assign counter = counter+1

Here is a quick screenshot to show what I mean better and show how to concatenate the filename by replacing the Extension:

I hope this helps.

EDIT: also “filepath” is a variable pre-declared as = “C:\Private\New folder\SKM-RE_Scheduling-20180521.xlsx” or = “C:\Private\New folder\SKM-RE_Scheduling.xlsx” and concatenate the date in too.


1 Like

Oops. Also, use – Not File.Exists() in the “Is True” so it will Retry until the filepath does Not exist.

Not System.IO.File.Exists(filepath)

Thank u so much for the solution. It really helped me