{{fbdoc item="title" value="NAME"}}----
Renames a file on disk

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Name**( [[KeyPgByref|byref]] //oldname// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByref|byref]] //newname// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgLong|long]]
##
{{fbdoc item="usage"}}##
	//result// = **Name**( //oldname//, //newname// )
##
{{fbdoc item="param"}}
	##//oldname//##
		Name of an existing file.
	##//newname//##
		New name of the file.

{{fbdoc item="ret"}}
	Returns zero (##0##) on success and non-zero on failure.

{{fbdoc item="desc"}}
	Renames a file or folder originally called ##//oldname//## to ##//newname//##.
	
	The function is not guaranteed to succeed if a file/folder exists with the same name.  It may  succeed, overwriting the original, or it may fail.  For greater control, ##[[KeyPgFileexists|FileExists]]## could be used to test for an existing file, and ##[[KeyPgKill|Kill]]## could be used to delete an existing file beforehand.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/system/name.bas"}}%%(freebasic)
Dim OldName As String
Dim NewName As String
Dim result As Integer 

OldName = "dsc001.jpg"
NewName = "landscape.jpg"

result = Name( OldName, NewName )
If 0 <> result Then 
	Print "error renaming " & oldname & " to " & newname & "."
End If
%%

{{fbdoc item="diff"}}
	- In QB, NAME required AS rather than a comma between the old and new names.  This is because NAME was a language keyword rather than a function.

{{fbdoc item="see"}}
	- ##[[KeyPgKill|Kill]]##
	- ##[[KeyPgFileexists|FileExists]]##

{{fbdoc item="back" value="CatPgOpsys|Operating System Functions"}}