Handy rsync
commands for efficiently moving files between directories on macOS, with flags to preserve metadata, show progress, and remove source files.
rsync
is a powerful file transfer utility, often used for backups, syncing, and moving files locally or over a network. Below are common usage examples tailored for local file moves on macOS:
Basic syntax
rsync [options] source destination
Recommended options:
- -a
: archive mode (preserves permissions, timestamps, symlinks, etc.)
- -h
: human-readable output
- --progress
: shows progress during transfer
- --remove-source-files
: deletes original files after successful transfer
Examples
Move .mp4 screenshot recordings from Dropbox to the videos folder:
rsync -ah --progress --remove-source-files /Users/nic/Dropbox/Screenshots/*.mp4 /Users/nic/vid
Move all files from Movies/Recordings/ to a shorter path vid/:
rsync -ah --progress --remove-source-files /Users/nic/Movies/Recordings/ /Users/nic/vid/
Note: If the source ends with a /, the contents of the directory are copied. If not, the entire directory is copied into the destination.
Useful additions:
- Add --dry-run
to test without making changes.
- Add --delete
to remove files in the destination that no longer exist in the source (only use with care).