mv

mv(src::AbstractString,dst::AbstractString; remove_destination::Bool=false)

Move the file, link, or directory from src to dst. remove_destination=true will first remove an existing dst.

Examples

julia> mv("oldfile.txt", "newfile.txt")

This example moves the file "oldfile.txt" to "newfile.txt" in the current directory.

julia> mv("path/to/source/file.txt", "path/to/destination/")

This example moves the file "file.txt" from the "source" directory to the "destination" directory.

julia> mv("source/file.txt", "destination/newfile.txt", remove_destination=true)

This example moves the file "file.txt" from the "source" directory to the "destination" directory, and if a file with the same name already exists in the destination, it will be removed before moving.

julia> mv("directory", "new_directory")

This example renames the directory "directory" to "new_directory" in the current directory.

Common mistake example:

julia> mv("nonexistent_file.txt", "destination/")
ERROR: SystemError: source `nonexistent_file.txt` does not exist

In this example, the source file "nonexistent_file.txt" does not exist, causing a SystemError. Ensure that the source file or directory exists before using the mv function.

See Also

abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: