For this %ToFile% is your entire filepath and filename for the file you are trying to save, so it would already be defined at this point:
Set variable %VersionCounter% = 0
Label: CheckFile
If file exists %ToFile%
Set variable %VersionCounter% = %VersionCounter + 1%
Append _(%VersionCounter%) to Text %ToFile% ' now %ToFile% has the number on it such as filename_(1)
Go to Label CheckFile 'this will loop back around and make sure filename_(1) is available.
End (if) 'it will only come here if the file doesn't exit
Rename File
Good luck!