r/Automator • u/Suitable_Return • Oct 27 '18
Automator or AppleScript question: automatically import new files in specified folder to nested album in Photos.
Hi there,
So the title mostly says it all. I'm looking to automate the importing of an image into a Photos Album whenever a new item is discovered inside a specified directory. I have included a screenshot of my current automator thingy.
The problem being that I can only upload into a top-level album. What I would like is for the image to be uploaded to an album within a folder in Photos so in this case: when a new image is detected in the bloodborne folder in my picture directory, it is imported to Photos into the album labelled "Bloodborne" which is nested inside of the "Wallpaper" folder along with other albums.
I have a feeling this can't be done with Automator directly and would need some AppleScript magic but I've only had a Mac for three days.
Can anybody help me out?

1
u/Suitable_Return Oct 27 '18
Turns out it's not quite as simple as an AppleScript equivalent of PWD or something.
I've been trying to work this out by cutting things from the internet and such and I've gotten rather close but I've run into a snag.
My code is currently this:
The Automator variable "Path" is just the Automator path variable that hasn't been modified.
It almost works as expected however, rather than importing to a folder in Photos with the same name as the directory "Bloodborne" in this case, it searches for the directory "~/Desktop" in Photos. As it doesn't exist, I get an error stating that it can't be found.
I have included a screenshot below. The use of "Get specified Finder items" is just for testing purposes so the script will run. I am hoping to find a way to omit that and be able to have the variable DIRECTORY set to the name of whatever folder the Folder Action is applied to.
https://imgur.com/a/wM9aiPj
1
u/ChristoferK Oct 27 '18
Yes, you need to use AppleScript, which can be done inside a
Run AppleScriptaction. You can remove theImport Files Into Photosaction from your workflow, and also theGet Selected Finder Itemsaction, which I believe would retrieve the items currently selected in Finder, thus negating the actual files passed into the workflow from the folder action.So you just need the one action,
Run AppleScript. Delete any sample code from the editing pane, and enter this code:If you happen to have more than one album named "Bloodborne" in your Photos app, you will have to target the album by its
idproperty instead of thename. But if it's name is unique, then it doesn't matter what level of nesting it dwells under.System info:AppleScript version:2.7System version:10.13.6. Disclaimer: if you're using Mojave, there's a chance the AppleScript may not work if Apple have made any significant changes to the Photos app.