Advanced merge directory tree with cp in Linux
- by mtt
I need to:
Copy all of a tree's folders (with all files, including hidden) under /sourcefolder/* preserving user privileges to /destfolder/
If there is a conflict with a file (a file with the same name exists in destfolder), then
rename file in destfolder with a standard rule, like add "old" prefix to filename (readme.txt will become oldreadme.txt)
copy the conflicted file from source to destination
Conflicts between folders should be transparent - if same directory exists in both sourcefolder and destfolder, then preserve it and recursively copy its content according to the above rules.
I need also a .txt report that describes all files/folders added to destfolder and files that were renamed.
How can I accomplish this?