File.move
$file.move($toPath, $options={}) -> $toPath
Description
Move the file to a new path.
If the destination path already exists, an error will be triggered.
It returns the new path of the moved file.
$fromFile = file'files:/dir1/data1.txt' $toFile = file'files:/dir2/data2.txt' $fromFile.move($toFile)
Moving to a Directory
If the destination is a dir
path, the filename will remain the same.
$fromFile = file'files:/source/data.txt' $toDir = dir'files:/target' $newPath = $fromFile.move($toDir) //= file'files:/target/data.txt'
Options
Option | Value | Description |
---|---|---|
overwrite |
true/false | Overwrite the target if it already exists. |
$fromFile.move($toFile, -overwrite)