Reputation: 11
Running on an OSX 10.9 box. In a bash terminal I am trying to copy files from dir a
to dir b
, deleting the files from dir a
as they are copied over.
I am using the following command:
rsync -av --delete -after /a/* /b
The files from a
copy over to b
, but the files in a
are still there after the transfer.
Upvotes: 1
Views: 10450
Reputation: 127
If you are at all worried about inadvertently removing directories that didn't transfer correctly when using (from the previous post)
rm -rf /a/*
then you can use a slightly safer way of removing the empty sub-directories with 'find'.
rsync -av --remove-source-files /a/ /b/ && find /a/ -type d -empty -delete
Upvotes: 2
Reputation: 1834
That's not what --delete
does. --delete
(and its variations like --delete-after
) don't delete files from the source a
, they delete files from the target b
that do not exist in the source. The argument you are looking for is --remove-source-files
.
Try rsync -av --remove-source-files /a/ /b/
Upvotes: 12