Automator copy/overwrite file if newer

Hi folks. I have searched, I can see similar discussions, but not this one. I'm sure it must have been covered, but I can't find it.


I've been playing about with Automator (I'm fairly new to mac) and I've set up a couple of .apps which copy files to a backup NAS. This works ok but there are no condition options.


I need the app to copy files from the source to the destination and overwrite but ONLY if the file is newer. On a PC I would check the A attribute, or the last changed date.


Surely this is pretty simple to achieve, I just can't find it. I will continue to search, but I would appreciate any help.


Thanks.

MacBook Pro with Retina display, OS X El Capitan (10.11.3)

Posted on Jul 10, 2016 4:19 AM

Reply
3 replies

Jul 10, 2016 12:58 PM in response to Barney-15E

I have a folder "MYBACK" on a usb drive in which I drop files I wan't backed up.

I want to run the backup to copy the files off to a NAS.

Then I want to free up space and delete the files in the local folder "MYBACK".


I couldn't see the perfect solution in cp, rsync or ditto.


The cp command is too destructive. Full Stop.


The rsync documentation states: -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)

But I can't find clarification in any of the help I've seen exactly how files will be handled. Basically I need the functionality of DOS xcopy /m/e/y


/m Only copy files with the A attribute (it's new or it's been changed since last copied), and reset the attribute.

/e Copy/create all subdirectories even if empty.

/y Overwrites files without prompting.


In this case files will be copied from source to destination ONLY if they are new or they've been modified. All sub folders are dealt with and very importantly files in the destination that don't exist in the source won't be deleted.


It looks as if "ditto" has been created for this kind of thing, but apparently it's not very reliable, and I don't want to merge folders.


I can't believe this can't be done!


Please don't suggest TimeMachine, that's not what I want to do at all!


Any help gratefully received.

Thanks.

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.

Automator copy/overwrite file if newer

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