How to replace all the contents from one folder with another one
Use rsync
. It will synchronize the directories in one direction. So, if you want to update your old
folder with everything from new
, but keep what's in there, just use:
rsync -avh --dry-run /path/to/new/ /path/to/old/
This will, in a first instance, just output the list of files that would be transferred. In that case: Everything found in new
will be copied to old
, unless it's already there. Everything in old
stays as it is.
If it looks fine to you, remove the --dry-run
argument to transmit them for real.
The -avh
flags just enable archive mode (which will preserve timestamps, etc.), verbosity and human-readable file-sizes. Nothing will be deleted from the destination unless you specify the --delete
flag. Consult man rsync
for more information.
rsync would probably be a better option here. It's as simple as rsync -a subdir/ ./. check this unix.stackexchage answer for better solutions
use -f
with the cp
command
cp -fR /source/files /dest
suppress cp to overwrite" prompt..
To override cp's alias you can simply enclose it in quotes:
'cp' -rf ./source/* /destination/
for more information follow these links:
http://www.wallpaperama.com/forums/cp-command-problems-forcing-overwrite-using-cp-command-t5685.html
http://bytes.com/topic/unix/answers/865372-force-cp-overwrite-existing-directory