How to export all favorited pictures from Photos.app and movies to a zip file

688 views Asked by At

I'd like to export all of my favorited photos/videos on a weekly basis to a zip file or directory. Is there an apple script/automator workflow that can do this that I can schedule to run?

Thanks for your response, I've tried what you suggested but get this error (please note that automator is automatically changing the text "using originals true" to "with using originals": enter image description here

1

There are 1 answers

6
ThatsJustCheesy On BEST ANSWER

If we open up the scripting dictionary for Photos and search for “favorite”, we see the following:

“favorites album” in Photos scripting dictionary

There is an album object available from the root Photos application that contains all of your favorited items. Perfect! Now we need to export them… dictionary, what do you have to say on the matter?

“export” command in Photos scripting dictionary

There is a command in Photos that exports specified media items to a filesystem location. That's exactly what we need! So, so far, we have this in our script window:

tell app "Photos"
    export every media item in favorites album to [export location here] ¬
        using originals true
end

Obviously, you should replace [export location here] with the location you want to export to (via a file or POSIX file specifier). If you want to compress them into a zip file now, that should be pretty easy, too. In this case, since this functionality isn't provided by any preinstalled system application (that I am aware of), we can outsource the job to a command line utility called zip:

set quoted_out_location to quoted form of POSIX path of [export location here]
do shell script "zip -r " & quoted_out_location & space & quoted_out_location

And that's it! From there you can move the resulting zip file wherever you need using System Events or Finder or whatever you please, and delete the intermediate folder if you want. If this needs to run automatically on a regular basis, the easiest option by far is to embed the script in an Automator Calendar Alarm workflow, and attach it to a recurring calendar event. That's not too hard to find with a quick Google search, and this answer is long enough already.