Hi guys! i want to write speedy and very fast code to check if chosen filename exists then add "-1" at end of it and if chosen filename exists again, add "-2" instead of "-1" and check filename until be unique.
For Example: I have to write "Filename.txt" in C:\ directory with
FileOpen
then check if "Filename.txt" exists in that directory then rename chosen filename to "Filename-2.txt" and if exists again in directory, rename chosen filename to "Filename-3.txt" and do this w
Or maybe something like:
#include <File.au3>
ConsoleWrite(_UniqueFileName(@ScriptDir & "\Filename.txt") & @CRLF)
Func _UniqueFileName($_sFilePath)
If FileExists($_sFilePath) = 0 Then Return $_sFilePath
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit($_sFilePath, $sDrive, $sDir, $sFileName, $sExtension)
Local $i = 1
While 1
$_sFilePath = $sDrive & $sDir & $sFi