({{, (RefLink[RenameFile, paclet:ref/RenameFile])[(Subscript[file, 1]),(Subscript[file, 2])]
renames (Subscript[file, 1]) to (Subscript[file, 2]). }})

OpenersNotesSection(Spacer1)Details and Options

(Subscript[file, 1]) must already exist; (Subscript[file, 2]) must not.

(RefLink[RenameFile, paclet:ref/RenameFile]) sets the modification date for (Subscript[file, 2]) to be the same as for (Subscript[file, 1]).

(RefLink[RenameFile, paclet:ref/RenameFile]) returns the full new file name, or (RefLink[$Failed, paclet:ref/$Failed]) if the file cannot be renamed.

(RefLink[RenameFile, paclet:ref/RenameFile]) works on cloud objects, changing their cloud file names but not their UUIDs.

Files can be specified either using "path" or (RefLink[File, paclet:ref/File])["path"].

(RefLink[RenameFile, paclet:ref/RenameFile]) has the following option:

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Copy a file:

file = $InstallationDirectory<> "/Documentation/English/System/ExampleData/ocelot.jpg";

cfile1=FileNameJoin[{$TemporaryDirectory,"ocelot.jpg"}];

CopyFile[file,cfile1]

Rename the file:

cfile2=FileNameJoin[{$TemporaryDirectory,"test123"}];

RenameFile[cfile1, cfile2]

Import the renamed file:

Import[cfile2]

Delete the file:

DeleteFile[cfile2]

OpenersExampleSection1(Spacer1)Scope  (1)

Rename a file specified by the (RefLink[File, paclet:ref/File]) object:

file=File[CreateFile[]]

newfile=File[FileNameJoin[{$TemporaryDirectory,CreateUUID[]}]];

RenameFile[file,newfile]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CopyFile, paclet:ref/CopyFile])  ▪  (RefLink[DeleteFile, paclet:ref/DeleteFile])  ▪  (RefLink[RenameDirectory, paclet:ref/RenameDirectory])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Files and Directories, paclet:tutorial/ManipulatingFilesAndDirectories])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Cloud Functions & Deployment, paclet:guide/CloudFunctionsAndDeployment])}, {▪(RefLinkPlain[Managing Content in the Cloud, paclet:guide/ManagingContentInTheCloud])}})}})