Saving multiples files to a directory in a way that names them differently

Hi. I need to have my bot save a file to a directory. THis is easy enough, I send hot key with ctrl+S and type into for a file name, then press save.

The problem is that I need this to repeat. When I save the second file I need the bot to know to name it something else so that it a) does not override the last file and b) does not stall the bot with a windows prompt asking if it is okay to override.

I am trying to avoid having a user have to predefine all the file names because often a user will run this bot not knowing the total number of files that will eventually be saved to the directory.

I am wondering how one might achieve this.

Have a look here

Another technique is to retrieve the files with Directory.GetrFiles(“C:\FolderPath\ABC*.ext”)
and counting the results for using it in the new filename

and more direct with Directory.GetrFiles(“C:\FolderPath\ABC*.ext”).Length

Therefore the methods below are helping much:

1 Like