It seems like very basic command. However even after an hour of searching the solution, I still can't find something that works.
So I have two big folders (with many files and many subfolder, the mega back-up). I'd like to combine these two folders into one folder that contains only newer files. So I'm searching a way to overwrite files IF ONLY source file is newer than the destination file, or when the destination file does not exist.
I'm running Mac version 10.7.4. I'm open to installing new application and/or using terminal/bash command.
In Gnu systems, use mv -u SOURCE DEST
or cp -u SOURCE DEST
to move or copy only when the SOURCE file is newer than the DEST file or when the destination file is missing.
Note that in OS X, mv and cp don't support the -u
option. However, rsync has a -u
option and it is supported on OS X. For example:
rsync -aru SOURCE/ DEST
Run some tests in scratch directories before applying it to large and important directories, because (IMO) rsync is idiosyncratic regarding whether directory names end with or without a /
. Part of the Linux man page says:
A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With