I am wanting to move (not just copy) a group of files/directories to a different directory some of which have name clashes with files/directories in the target directory. My main objective is to move the files, so I can tolerate the non-empty directory being overwritten.
I am currently using mv ... destination
however, occasionally I get
mv: cannot move `target' to /destination/target': Directory not empty
I tried mv -f ... destination
with no success and since I want the files to be gone from their original location, rsync
doesn't seem to be appropriate.
As a bonus, is there a good solution for preserving the files intended to be overwritten somehow maybe by renaming?
Best Answer
If you use
mv --backup=numbered
(or one of the other options for the
--backup
switch),then
mv
will complete the merge and preserve the files intended to be overwritten.