copy files newer than to a folder?


I made an initial backup of a folder containing many photos in a deeper folder structure. I wonder if I can make use of the Automator to reach this:

I’d like to have a work flow that will start at a given root folder and looking for files changed or newer after a given date. Then if found the work flow should start to copy the changed or new files to a given location with exactly the same folder structure to be able to make a backup of these files.

Well as I’m new to my MAC (I’m a switcher and asking why I didn’t have done this earlier :slight_smile: and of course Automator
I’d like to ask you as a specialist… :wink:

Can you please let me know…?



Hi Yogie,

for this purpose there is a powerful built-in function rsync, which is accessible with a shell command.
This AppleScript asks for a source and destination folder, then copies all new or changed files from source to destination keeping the folder structure.
The --delete flag deletes all files at destination, which are not longer available at source.

set sourceFolder to quoted form of POSIX path of (choose folder with prompt "Source folder")
set destinationFolder to quoted form of POSIX path of (choose folder with prompt "Destination folder")
do shell script "/usr/bin/rsync -autE --delete " & sourceFolder & " " & destinationFolder

You can also hard-code the paths

do shell script "/usr/bin/rsync -autE --delete '/path/to/source/folder/' '/path/to/destination/folder/'"

or run the shell line (the literal string without the double quotes) from a run shell script action in Automator

Hi Stefan,

that sounds very good, but as I understand you correctly, within the Automator I only can use the hard coded line right?

Then I ask myself, is it possible to put the more comfortable script into a kind of a batch file and then run from Automator? Or why then using the Automator? :slight_smile:

Do I have to keep the destination folder? I would like to remove the destination folder after backing up the files of that…
So I do not see how I can give a specific date rsync is looking for? Or is it just a kind of compare command?

Thanks again for your reply and help to understand…



No, you are as flexible as you want. You can ask for the folders in Automator,
but you can also run the script without Automator.

I personally don’t use Automator at all, because as Automator is just a GUI for AppleScript, I can do all things directly in AppleScript

Do you mean the specified folder in the script or the real folder on disk (which wouldn’t make much sense)?
And what do you mean with the specific date rsync is looking for?
rsync copies all files which are newer than the last sync

With the destination folder I’m really talking about the folder on the disk, as this should be a temporary folder only, as I would like to burn this folder to a DVD to store it outside the MAC and any HDD.
So I asked if I have to keep the destination folder as I wonder how would rsync know what date I’m looking for to find newer and changed files?

My workflow looks like this…

I have a folder called “Photos” with tons of subfolders… into these subfolders I copy new photos from time to time or change them with giving new EXIF tags (f.e.g while geo-tagging images)
At a specific time I made a “backup” of the whole “Photos” folder onto 10 DL DVD’s.
Now I want to have a script to find out which files I added and changed after the date I made the “backup”, I need to have them copied to a new target folder (with the structure from the source) so that I can backup only the new and changed files.
After backing up these files I do not need the just created folder and files anymore as they are stored onto DVD’s and to make room on my hard disk.
After a period of time I will do the same again and then the script should find only the added/changed files after the date of the last backup…

I hope it’s now clearer what I like to do?

Cheers and thanks again for your help!

DVD media are quite insecure. It could be, that future drives couldn’t read currently burned DVD’s

Better invest in an additional harddisk

:smiley: well this is not a solution…

Yes of course I do have another harddisk where I have a 100% copy of the folder and it is synced with CCC but nevertheless I want to have all the files on a DVD too and I’m still looking for a solution to this!

Ah woastas (bavarian german for something like “what the hell.” ;))

It would have been helpful to mention this DVD “backup” point in your first post.

I guess, there is no solution
How can a script compare files with deleted ones?

But if you have a harddisk backup anyway, the script could copy the new or changed files on the harddisk
and burn them also on DVD. rsync has a verbose mode to “log” the copied files