I have this script (provided by someone at macscripter.net) and if I use it using a predefined path to a file using the ScriptEditor, I can copy the file to the Photos app:
- Code: Select all
set imageList to (POSIX file "/Users/dannywyatt/My Files/Inbox Global/_Awesome Argument.mp4" as alias)
importToAlbum(imageList, "Testing")
on importToAlbum(imagePathList, albumName)
tell application "Photos"
set albumNames to name of albums
if albumName is in albumNames then
import imagePathList into album albumName
else
make new album named albumName
import imagePathList into album albumName
end if
end tell
end importToAlbum
Now when I try to use it in Hazel like this:
- Code: Select all
set imageList to theFile
importToAlbum(imageList, "Test")
on importToAlbum(imagePathList, albumName)
tell application "Photos"
set albumNames to name of albums
if albumName is in albumNames then
import imagePathList into album albumName
else
make new album named albumName
import imagePathList into album albumName
end if
end tell
end importToAlbum
It doesn't work. It highlights the "on" here: "on importToAlbum(imagePathList, albumName)" and at the bottom it says "Expected end, but found on".
Any tip on how to make this work?
Thank you