mv

Move files and/or folders.

Syntax

     mv [options] source target

Options
     -n     Do not overwrite any existing file.

     -i     Prompt before moving a file that would overwrite an existing file.
            A response `y' or `Y', will allow the move to proceed
            (writes to standard error)

     -f     Always Overwrite destination files
            (Do not prompt for confirmation)

     -v     Verbose, show filenames.

The -n and -v options are non-standard and their use in scripts is not recommended.

Examples

Move all files with names ending in ".jpg" from the current folder
to the Documents directory
  $ mv *.jpg ~/Documents

Move the "Documents" folder to "Documents backup".
  $ mv Documents "Documents backup"
quotes are needed because of the space in the folder name.

Rename .txt files to .html
  $ for f in *.txt; do mv ./"$f" "${f%txt}htm"; done 

“Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction” - Albert Einstein

Related:

mv man page - Apple.com
cp - Copy files
CpMac - Copy a file while preserving metadata and forks (Developer Tools)
copy - Copy groups of files in folders
dd - Data Dump - convert and copy a file (use for RAW storage)
install - Copy files and set attributes
MvMac - Copy a filewhile preserving metadata and forks (Developer Tools)
tar - store or extract files to an archive (allows symbolic links to be copied as links)



Back to the Top

© Copyright SS64.com 1999-2012
Some rights reserved