senthor Posted November 5, 2008 Posted November 5, 2008 As there is no real "FileRename" you have to Use FileMove("oldname.txt", "newname.txt") FileListToArray UDFMy tools
Andreik Posted November 5, 2008 Posted November 5, 2008 (edited) Another way(not so good like FileMove): RunWait(@ComSpec & " /C ren " & $file & " " & $newname, "", @SW_HIDE) Edited November 5, 2008 by Andreik
cypher175 Posted November 5, 2008 Author Posted November 5, 2008 As there is no real "FileRename" you have to Use FileMove("oldname.txt", "newname.txt") what if the file I want rename is the actual Script.exe and its already running how can I rename the script.exe while its still running..??
senthor Posted November 5, 2008 Posted November 5, 2008 (edited) Not that easy but possible too: If $CMDLine[0] > 1 and CMDLine[1] = "copy" and FileExists($CMDLine[2]) and @compiled = 1 Then Sleep(100) If $CMDLine[2] <> @autoitexe then FileDelete($CMDLine[2]) EndIf FileMove(@scriptfullpath, $newdir) Run('"' & $newdir & '" copy ' & @scriptfullpath) Exit senthor Edited November 5, 2008 by senthor FileListToArray UDFMy tools
cypher175 Posted November 5, 2008 Author Posted November 5, 2008 that seems like an awful lot of code just to simply rename a file.. Out of all the functions why is ''FileRename" not in there.. Why did they leave it out for..?? Its like a basic function..??
senthor Posted November 5, 2008 Posted November 5, 2008 Of course it is, but try to rename a exe file while it's running - won't work. Same problem here. So you have to copy the script, run the new one and delete the old after quitting it. FileListToArray UDFMy tools
cypher175 Posted November 6, 2008 Author Posted November 6, 2008 if you use a batch script to .exe app you can rename your script.exe while its running with this simple line: REN %~0 TEST.EXE and it works fine.. But with AutoIt you have to copy the script to a diff name, run the new script.exe which will delete the old script.exe..
cypher175 Posted November 6, 2008 Author Posted November 6, 2008 wait a sec, I just tried this code and it worked just fine.. FileMove(@ScriptName, "NewName.exe")
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now