Monday, March 2, 2015

How to move files with rsync

To move files using rsync i.e. to sync and then delete original folder use the following line:

sudo rsync -av --ignore-existing --remove-source-files /old/path/to/folder/ /new/path/to/folder/ && rsync -av --delete `mktemp -d`/ /old/path/to/folder/ && rmdir /old/path/to/folder/

--remove-source-files
removes files from original folder but not the original folder structure.
rsync -av --delete `mktemp -d`/ /old/path/to/folder/
removes subdirectories from original folder
rmdir /old/path/to/folder/
removes original folder

No comments:

Post a Comment