xcopy equivalent in terminal?

I am a long time PC user making a valiant effort to move to MAC. I am attempting to find a painless way to update a flash drive with some data that has to move between my office and home machines. There are a lot of files, but only a few change each day, and I have to make sure that an older file never overwrites a newer file with the same name.

On the PC I would simply fire up a command prompt and use the following xcopy command:

"xcopy path\dir1\ . path\dir2\ /s /h /r /c /d"

This would copy all of the files in dir1 to dir2, including all subdirectories (/s); including all hidden files (/h); including all read-only files (/r); continuing on, rather than erroring out, if a glitch develops (/c); and copying only files that are newer than those already in the target directory where the same file exists in both directories (/d)

I've been told that the "cp" command is what I want, but a review of the man file does not indicate anything similar to the /d parameter. Apparently some versions of the linux cp command allow a -u parameter, which seems to be similar, but OS X doesn't like that.

I need to make sure that an older file is never copied over a newer file, so the equivalent of the /d parameter is necessary.

What am I missing?

MacBook Pro 2.4 / MacPro 2.66, Mac OS X (10.4.10)

Posted on Jun 5, 2008 9:22 AM

Reply
3 replies

Jun 5, 2008 9:57 AM in response to bobritter

rsync is probably what you want. From the terminal, type "man rsync". It's got quite a few options, so try to read the man page carefully. You can also get a synopsis of the options available by doing this:

user% rsync --help | less

(the | less is just a way for you to paginate).

You should also keep in mind that, like NTFS and things like ACLs, alternate data streams, etc, the Mac has extended attributes, resource forks, etc so you'll want to be sure to preserve those when copying (which rsync can do, but probably won't do unless you tell it to).

There's probably also many rsync howto's on the Web that could get you started...

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xcopy equivalent in terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.