If I use mv to move a folder called "folder" to a directory that already contains "folder" will they merge or will it be replaced?
|
|
|
You can work around this using other tools (like
Which of these workarounds (if any) is appropriate will very much depend on your specific use case. 1: Note that |
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
|
You can use the
You may also want to use the |
|||||||||||||||||||||
|
|
I'd recommend these four steps:
or better yet, here's a script that implements semantics similar to
|
|||||||||||||||||
|
|
Here is a way that will merge the directories. It is much faster than rsync since it just renames the files instead of copying them and then deleting them.
|
|||||||||||||||||||||
|
|
One way to accomplish this would be to use:
As long as no two files have the same name in |
|||||||||||||||||
|
|
Here is a script that worked for me. I prefer mv over rsync, so I use Jewel and Jonathan Mayer's solutions.
|
|||||||||
|
|
It is not a good idea to use commands like cp or rsync. For large files, it will take a long time. mv is much faster since it only update the inodes without copying the files physically. A better option is to use the file manager of your operating system. For Opensuse, there is a file manager called Konquerer. It can move files without actually copying them. It has "cut and paste" function like in Windows. Just select all the sub-directories in directory A. Right click and "move into" directory B which may contain sub-directories with the same names. It will merge them. There are also options whether you want to overwrite or rename files with the same name. |
|||||
|
|
For the purest copies, I use the tar (-)B blockread copy method. example, from source path:
this creates an exact copy of the source tree, WITH the owner and permissions intact. And if the target folder exists, the data will be merged. Only files that are already existing will be overwritten. When the copy action is successful, you can remove the source ( As option you can be verbose (display on screen the file being copied), with -v:
|
|||||
|