On 2019/07/28 23:28, Assaf Gordon wrote: > > > $ mkdir A B B/A > $ touch A/bar B/A/foo > $ mv A B > mv: cannot move 'A' to 'B/A': Directory not empty > > And the reason (as you've found out) is that the target directory 'B/A' > is not empty (has the 'foo' file in it). > Had this been allowed, moving 'A' to 'B/A' would result in the 'foo' > file disappearing. > --- Why must foo disappear?
Microsoft Windows handles this situation by telling the user that the target directory already exists and giving the option to *MERGE* the directories. If you attempt to move a file into a directory that already contains a file by the same name, it pops up another notice asking if you want to replace the old with the new, keep it as it is (file won't be moved and in this case, old directory would still exist with the unmoved files left in it), or keep both with the new file getting a name variant (like foo.exe -> foo_1.exe, keeping the extension the same so as to not mess up the identity of the contents. But in all the cases, a file with a non-conflicting name wouldn't disappear from the target.