4D v19

file.rename( )

Home

 
4D v19
file.rename( )

file.rename( )  


 

The file.rename( ) method renames the file with the name you passed in newName and returns the renamed File object. 

The newName parameter must comply with naming rules (e.g., it must not contain characters such as ":", "/", etc.), otherwise an error is returned. If a file with the same name already exists, an error is returned. 

Note that the method modifies the full name of the file, i.e. if you do not pass an extension in newName, the file will have a name without an extension. 

Returned object

The method returns the renamed File object.

Example  

You want to rename "ReadMe.txt" in "ReadMe_new.txt":

 $toRename:=File("C:\\Documents\\Archives\\ReadMe.txt";fk platform path)
 $newName:=$toRename.rename($toRename.name+"_new"+$toRename.extension)

 
PROPERTIES 

Product: 4D
Theme: File and Folder

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)