flip209 Posted April 27, 2008 Share Posted April 27, 2008 (edited) CODE ;========================================================================== ;File Rename ;Returns: ;0 For successful ;1 For Did not enter File to be Renamed ;2 For Did not enter new file name ;3 For File Does not Exist ; _filerename($oldfilename, $newfilename) ;$oldfilename - enter the file you with to be rename including the full path ;$newfilename - enter the name you want it, but not the path ;Example - _filerename("c:\helpme.txt", "Idonotneedhelp.txt") ;Result c:\Idonotneedhelp.txt ;By Flip209 ;========================================================================== Func _filerename($oldfilename, $newfilename) $i = 0 Dim $string If $oldfilename = "" Then Return 1 ElseIf $newfilename = "" Then Return 2 ElseIf not FileExists($oldfilename) Then Return 3 EndIf $split = StringSplit($oldfilename, "\") Do If $i <> 0 Then $string &= $split[$i] & "\" $i += 1 Until $i = $split[0] $string &= $newfilename FileMove($oldfilename, $string) If FileExists($string) then Return 0 EndFunc ;==>_filerename MsgBox(0,"",$error) Returns: 0 if good 1 no source file 2 no name to rename to 3 file does not exist Edited April 27, 2008 by flip209 " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln Link to comment Share on other sites More sharing options...
flip209 Posted April 27, 2008 Author Share Posted April 27, 2008 Bum " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln Link to comment Share on other sites More sharing options...
Developers Jos Posted April 27, 2008 Developers Share Posted April 27, 2008 "Bum" What ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
flip209 Posted April 27, 2008 Author Share Posted April 27, 2008 LMAO I dropped the p it what suppose to be bump....LMAO My bad " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln Link to comment Share on other sites More sharing options...
Developers Jos Posted April 27, 2008 Developers Share Posted April 27, 2008 LMAO I dropped the p it what suppose to be bump....LMAO My badUnderstood as much, guess I was trying to tell you its annoying to Bump something this quickly that doesn't even contain anything that needs answering. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
NELyon Posted April 27, 2008 Share Posted April 27, 2008 Well... Returning 0 on success isn't such a good idea. Example: If _FileRename("Blah.txt", "Hi.txt") Then MsgBox(0, "Error", "There was an error") EndIf See FileMove Return Values in the helpfile to see what it should return Link to comment Share on other sites More sharing options...
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