Jump to content

Recommended Posts

Posted (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 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

Posted

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

Posted

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

  • Developers
Posted

LMAO I dropped the p it what suppose to be bump....LMAO My bad

Understood 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.
  :)

Posted

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 :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...