6.4.10RENAME FILE
Syntax
RENAME [TRUNCATE] FILE file_name [, file_name]* AS new_file_name [, new_file_name]*
Description
Rename (or move) an existing file named file_name as new_file_name. Multiple files can be renamed (or moved) at once by separating their names with a comma (,). If new_file_name already exists, it is not overwritten, no subsequent files are renamed (or moved), and an error is raised. To overwrite an existing file, specify the keyword TRUNCATE (all data stored in the file will be permanently lost).
Parameter(s)
file_name – mandatory string that specifies the name of the file to rename (or move).
new_file_name – mandatory string that specifies the new name and/or location in the file system to use for renaming and/or moving file_name.
Return
Nothing
Example(s)
# rename a file named "my_file0.h5" as "my_file1.h5" (the file "my_file1.h5" will not be overwritten if it already exists)
RENAME FILE my_file0.h5 AS my_file1.h5
# rename a file named "my_file2.h5" as "my_file3.h5" (the file "my_file3.h5" will be overwritten if it already exists)
RENAME TRUNCATE FILE my_file2.h5 AS my_file3.h5
# rename two files named "my_file4.h5" and "my_file5.h5" as "my_file6.h5" and "my_file7.h5", respectively (both files "my_file6.h5" and "my_file7.h5" will be overwritten if they already exist)
RENAME TRUNCATE FILE my_file4.h5, my_file5.h5 AS my_file6.h5, my_file7.h5
# move a file named "my_file8.h5" into a root directory named "data" and rename it as "my_file9.h5" (the file "my_file9.h5" will not be overwritten if it already exists in this directory)
RENAME FILE my_file8.h5 AS /data/my_file9.h5
# move a file named "my_file10.h5" into a relative directory named "backup" (the file "my_file10.h5" will not be overwritten if it already exists in this directory)
RENAME FILE my_file10.h5 AS backup/