renFile
Top  Previous  Next

renFile ( string Old, string New )

Use this function to rename or move a file or folder.

Parameters
 
Old  
 
A string specifying the path and name of the file or folder to be renamed. If the path is not specified, the default directory will be used. See setCurDir for more details.  
 
New  
 
A string specifying the new path and name of the file or folder. If the path is not specified, the default directory will be used.  
 
Error flags
ERR_OK  
 
The flag set if successful.  
ERR_FAILED  
 
The flag set if failed.  
ERR_NOTFOUND  
 
The flag set if the file was not found.  
 
ERR_NOSPACE  
 
The flag set if the file could not be moved to a new location.  
 
Remark
 
The old name must be the path of an existing file or folder. The new name must not be the name of an existing file or folder. You can use rename to move a file from one directory or device to another by giving a different path in the newname argument. However, you cannot use rename to move a folder. Folders can be renamed, but not moved.  
The specified path should comply with the standard notations for directory names in Windows operating system. When you use the optional backslash character (\) in paths, you must place two backslashes (\\) in a string to represent a single backslash (\). If the drive letter is omitted in Path, the current directory will be used as a reference.  
 
Example

The following code waits for an image file to appear in a folder and moves it to another folder  
 
inPath="c:\\in\\"  
outPath="c:\\out\\"  
fMask="*.iwd"  
do  
 'wait for image  
 while getFileCount(inPath+fMask)=0  
  wait(10)  
 wend  
renFile(inPath+fMask, outPath+fMask)  
loop