Function Reference


_FO_FileDirReName

Renames a file or directory.

#Include <FileOperations.au3>
_FO_FileDirReName ( $sSource, $sNewName [, $iFlag=0 [, $DelAttrib=0 [, $iDir=-1]]] )

Parameters

$sSource The full path of the directory or file
$sNewName The new name
$iFlag [optional] Flag to overwrite existing
    0 - do not overwrite existing file/directory (default)
    1 - overwrite the existing file (if the directory already exists, it will be deleted)
$DelAttrib [optional] Remove the attributes (-RST), if it is not possible to remove a file/directory
    0 - do not remove the attributes (default)
    1 - remove attributes
$iDir [optional] Specifies what is $sSource
    -1 - auto detection (by default)
    0 - file
    1 - directory

Return Value

Success:Returns 1.
Failure:Returns 0 and sets @error:
@error:0 - No error
1 - FileMove or DirMove failure
2 - $sNewName - an empty string
3 - $sSource - file/directory at the specified path does not exist
4 - the original and new name are the same
5 - $sNewName - contains invalid characters

Remarks

If you use $iFlag = 1, and a new file/directory with the same name exists, it will be removed, i.e. will not merge directories. Renaming is case sensitive.

Example

; AZJIO
; http://www.autoitscript.com/forum/topic/133224-filesearch-foldersearch/
#include <FileOperations.au3>

_FO_FileDirReName('C:\file.txt', 'New_Name.txt')
MsgBox(0, 'Message', '@error = ' & @error)