Friday 14 April 2017

rsync with remove source files and directory

Command line to copy files and then remove the source (iow. simulate the mv command with rsync)


Terminal command for hard-restart
rsync -aP --remove-source-files /source/aa/bb/subfolder /destination/subfolder/ && rm -R /source/aa/bb/subfolder

Command line options used:

rsync:

-a  = archive
P   = progress
--remove-source-files  = remove the source files that were transferred successfully (not the source directory)

bash:

&& = will only execute if previous command successful

rm:

-R  = recursive (remove files and directories) that way both the files and directory are removed.