mv

rename and move files and directories 

Command


SYNOPSIS

mv [-adfiv] file1 file2

mv [-fiv] file ... directory

mv -r [-fiv] directory1 directory2


DESCRIPTION

mv renames files or moves them to a different directory. If you specify multiple files, the target (that is, the last path name on the command line) must be a directory. mv moves the files into that directory and gives them names that match the final components of the source path names. When you specify a single source file and the target is not a directory, mv moves the source to the new name, by a simple rename if possible.

If a destination file exists and you do not have write permission for it, mv prompts with the name of the existing file. If you answer y or yes, it deletes the destination and then moves the source.

If the file being moved is a sparse file and the file system to which it is being moved does not support sparse files, mv warns that the resulting file will be larger. If the -i option was also specified, mv asks you if want to expand the file or skip it.

Options

-a 

moves the ACLs associated with the specified file along with the file itself. When used with -p, permissions are moved as well.

This option is only available on NTFS file systems.

Note:

When you use mv to do a simple rename (that is, simply move it on the same device), ACLs are automatically moved with the file and the -a option is not required. However, when you use mv to move a file to another device, you must specify the -a option or the ACLs are not moved with the file.

-d 

delays moving the specified files until the system is rebooted.

This option relies upon the underlying operating system's capability to perform the action at reboot time.

-f 

does not ask if you want to overwrite an existing destination without write permission; it automatically behaves as if you answered yes. If you specify both -f and -i, mv uses the option that appears last on the command line.

-i 

always prompts before overwriting an existing file, whether or not the file is read-only. If you specify both -f and -i, mv uses the option that appears last on the command line.

-q 

suppresses warning messages. Error messages are still displayed.

-r 

moves directory and all its contents (files, subdirectories, files in subdirectories, and so on). For example, mv -r dir1 dir2 moves the entire contents of dir1 to dir2/dir1. mv creates any directories that it needs.

-v 

prints file names to standard output as they are being processed.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— argument had trailing slash (/) but was not a directory
— file could not be found
— input file could not be opened for reading
— output file could not be created or opened for output
— read error occurred on an input file
— write error occurred on an output file
— input and output files were the same file
— input file could not be unlinked
— input file could not be renamed
— fatal error was encountered when using the -r option
Possible fatal -r errors include the following:
— inability to access a file
— inability to read a directory
— inability to remove a directory
— inability to create a directory
— a target that is not a directory
— the source and destination directories are the same
2 

Failure due to any of the following:

— invalid command line option
— too few arguments on the command line
— a target that should be a directory but is not
— no space left on the target device
— out of memory to hold the data to be copied
— the inability to create a directory to hold a target file

cannot allocate target string 

mv has no space to hold the name of the target file. Try to free up some memory to give mv more space.

filename read only? 

You are attempting to move a file, but there is already a file with the target name and the file is read-only. If you really want to write over the existing file, type y and press ENTER. If you do not want to write over the existing file, type n and press ENTER.

source "name" and target "name" are identical 

The source and the target are actually the same file (for example, because of links on UNIX and POSIX-compliant systems). In this case, mv does nothing.

unreadable directory "name

mv cannot read the specified directory (for example, because you do not have appropriate permissions).


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.

The -d, -q, -r, and -v options are extensions to the POSIX standard. The -d and -s options are only available on Windows.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Windchill Requirements and Validation


SEE ALSO

Commands:
cp, ln, pending, rm


PTC MKS Toolkit 10.4 Documentation Build 39.