Rename - Maple Help

FileTools

 Rename
 rename a file

 Calling Sequence Rename(old, new, opt1)

Parameters

 old - string; source filename new - string; destination filename opt1 - (optional) name; argument

Description

 • The Rename(old, new) command moves the file old to the new location new.
 • The Rename function does not return anything.
 • The optional argument force controls Rename's behavior when a file named new exists.  If force=false then an error is raised and the renaming does not occur.  This is the default behavior.  If force=true then the file is replaced by the renaming.
 • If either new or old refers to an open file, it is automatically closed before the move.
 • If the user does not have permission to perform the operation, an exception is raised.

Examples

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteLine}\right]\left("testfile","this is a test"\right)$
 ${15}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Rename}\right]\left("testfile","testfile2"\right)$

The file "testfile" cannot be read because it has been renamed.

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadLine}\right]\left("testfile2"\right)$
 ${"this is a test"}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile2"\right)$