Skip to content

Move File

Type: move-file  ·  Package: Filesystem Activities v1.0.6  ·  Output: string

Moves a file from a source path to a destination. The original no longer exists in its previous location. As a special case, if source and destination are in the same folder with different names, it renames the file. Widely used to archive processed documents or reorganize downloaded files.

Moves the file at source to destination.

  • Destination: destination is the full path of the file (folder + name), not just the folder.
  • Folders: if the destination folder does not exist, it is created (with any intermediate ones).
  • Overwriting: by default it does not overwrite: if the destination exists, it fails (unless overwrite = true).
  • Across drives: within the same drive the move is instant; to another drive or a network folder, the file is copied and then the original is deleted.
  • Files only: it does not move folders.
ParameterTypeDefaultDescription
sourcestring—Path of the source file.
destinationstring—Full destination path (or new name, in the same folder).
ParameterTypeDefaultDescription
overwriteboolfalseReplace the destination if it already exists.

Returns a string with the destination path of the moved file (as you gave it in destination).

MessageCause and fix
Could not find file '…'.The source file does not exist (maybe it was already moved by an earlier attempt). Check it with File Exists.
Cannot create a file when that file already exists.The destination exists and overwrite is false. Set overwrite = true or add something unique to the name (date, id).
The process cannot access the file '…' because it is being used by another process.The file is open in another program.
Access to the path '…' is denied.No permission on the source or the destination folder.
'source' is required. / 'destination' is required.The parameter’s expression evaluated to null.

Archive after processing and log where it went:

Move File source = path destination = pathJoin("C:/processed", fileName(path)) → output: archived
Log message = "Archived at " + archived

Rename:

Move File source = "C:/data/temp.csv" destination = "C:/data/customers_final.csv"