Skip to content

Rename_File

Include: Use System\FileSystem.pkg

See Also: Copy_File, Erase_File, File_Exist

Purpose

Renames or moves files and directory contents.

Syntax

Rename_File [FILE] {Source} to {Destination}

Arguments

FILE : Optional file driver. The FILE driver is optional; when omitted, file operations use FILE.

{Source} : Source file, folder, or wildcard pattern.

{Destination} : Destination file or folder.

Behavior

  • Rename_File FILE "old.txt" to "new.txt" renames or moves a file and removes the source.
  • Renaming a directory into an existing directory moves its contents there.
  • *.txt moves top-level matches only.
  • **.txt moves recursive nested matches into the destination.

Example

Rename_File FILE "old.txt" to "new.txt"
Rename_File "test1" to "test2"
Rename_File "test1/*.txt" to "test2"
Rename_File "test1/**.txt" to "test2"