Name

File management function.

The Name function renames or moves one or more files.

Usage

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. Wildcards (* or ? characters) are allowed in the file names.

Syntax

Name(<old_filename>,<new_filename>)
or
ret=Name(<old_filename>,<new_filename>)

Parameters

<old_filename>, string, name of the file(s) to be renamed. Wildcard characters are permitted.

<new_filename>, string, new name of the file. If the path of <new_filename> exists and is different from the path of <old_filename>, the Name function moves the file to the new directory and renames it. If <old_filename> and <new_filename> have different paths but the same filename, Name moves the file to the new directory but doesn't change the filename. The file <old_filename> must exist and the file <new_filename> must not exist. They must both be on the same drive.

Return value

Ret, numeric return code. When the rename is successful, the function returns 0, otherwise use this return code for Error Handling.

Remarks

The function works like the DOS statement RENAME. Name can also modify the name of a directory. Name cannot rename a file within the same directory, for example Name("c:\test\name1.txt","c:\test\name2.txt") returns an error. Use FileCopy instead and then Kill the original file.

Examples

 

Name("c:\mytext\toto.*", "c:\mytext\titi.*") ' Renames files c:\mytext\toto.* to c:\mytext\titi.*

 

Name("c:\mytext\toto.txt", "c:\docs\toto.txt") ' Moves the file toto.txt from c:\mytext\ to c:\docs\

 

 

Result = Name(Fi1e1$, File2$)