Benches macOS

5

xcopy equivalent?

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I posted this in the Leopard forum, but it appears that I was incorrect in doing that, so...

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 pathdir1
. pathdir2 /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?

thanks...Bob

5 replies

Sign in or join Beachball Help to reply.

  1. 0

    glsmith

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    See my post in that forum where I suggested "rsync" 🙂

  2. 0

    nobody loopback

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    yes,

    rsync -av sourcepath destpath

    rsync has many options, but the above will match xcopys behaviour.

    Compared to xcopy, rsync will work better then xcopy if you need to copy files through a slow wan connection.

  3. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    You need to add -u

    rsync -auv src dest

  4. 0

    bobritter

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    That did the trick - Thanks

    now if I can only get it to run as a script...

  5. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    now if I can only get it to run as a script...

    That is easy.

    #!/bin/sh

    rsync -auv src dest

    Make sure the file has <LF> Unix style line ending (using a shell editor such as
    nano will do that, or TextWrangler if you want a gui editor).

    Make sure the shell script is executable

    chmod +x filename

    Or create an Automator script and use the *Automator -> Utilities -> Run Shell Script* action and now you have a double clickable script.