How to Create new File with a Counter in the Name

Hi everyone!

I want to download a file everyday but I want to check if it exists in a specific folder and, if so, I want to increase the counter. For instance, if file name Test_V2 exists, I want to save it as Test_V3. How can I accomplish this?

Hi @sidb,

Pass your file path in input argument, it will return required file path.
FileExistsRename.xaml (5.2 KB)

Thanks!

Thank you.
I do have the file path. I actually just want to know which is the latest existing version of the file, get that version number as a variable and increase it by 1.

FileExistsRename.xaml (5.7 KB)

  • Updated the code. Pass your file path as C:\ReqFolder\Test.txt

It will check file exists or not, it will return required version of file name.

I had a scenario where I needed to do something similar, in my case I didn’t really need to consider what the version was, we just needed to see what the newest file was. So rather than a count, I added the current date/time into the filename. We added MMDDYYY hh:mm, so as long as you didn’t run it twice within the same minute, you’d always get a unique name.

Just something to consider.