Home > Language Reference > File Functions > Name


The Name function moves or renames one or several files from the source path to the specified destination path.


Do not move files using Drag and Drop in Explorer; drag and drop automation is not reliable as the way to display files in Explorer depends on Windows settings for each user. Use instead Name function.




<source_filename>, string, file(s) to rename or move. To specify more than one file use wildcard characters (* or ?).

<target_filename>, string, new name of the file. If <target_filename> path exists and is different from <source_filename> path, the Name function moves the file to the new folder and renames it. If <source_filename> and <target_filename> have different paths but the same filename, Name moves the file to the new folder but does not change the name of the file. The file <source_filename> must exist and the file <target_filename> must not exist. They must be both on the same drive.

Return value

ret, optional numeric return value. If the function succeeds, the return value is 0. If the function fails, the return value is a nonzero value (see File Functions Error Codes).


Name function works like the DOS RENAME function. Name can also modify the name of a folder. Name cannot rename a file within the same folder, for example:
returns an error. Use FileCopy instead and then Kill the original file 

See also



Name("c:\wttest\toto.*", "c:\wttest\titi.*") ' Rename files c:\wttest\toto.* to c:\wttest\titi.*
Name("c:\wttest\toto.txt", "c:\docs\toto.txt") ' Move the file toto.txt from c:\wttest\ to c:\docs\
Result = Name(Fi1e1$, File2$)