Is it possible to send a photo or video directly to an album inside Photos.app?
I found this article, but I can’t seem to understand how to use it myself, even with some changes (I’m a super-beginner when it comes to AS)
https://discussions.apple.com/thread/252917619
tiagorocha1979. This is easily done with the Shortcuts app, although it requires macOS Monterey or newer. Do the following:
- Download and install the shortcut linked below (it’s easily uninstalled).
- Select one or more photos in a Finder window.
- Run the shortcut by way of the shortcut menu in the upper-right section of the macOS menu bar, and select a photo album when prompted.
- Modify the shortcut’s save action to specify a particular photo album (avoiding the prompt) if that’s desired.
You may want to add some error correction to insure that the file selected in a Finder window is a photo or video but that’s not essential.
Photo Save.shortcut (22.0 KB)
@tiagorocha1979
Here is a AppleScript that will import selected images to an album name.
If the album name do not excist it will create it. You could import multiply selections.
set imageList to (choose file of type {"jpg", "jpeg", "tif", "tiff", "png", "gif"} with multiple selections allowed)
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
Thank you for sharing. Unfortunately I don’t have Shortcuts (yet). Still on Catalina.
But the script shared by @Fredrik71 did the trick!
Wow. Awesome! Worked like a charm! I added “mp4” as well, since that’s a format I will be importing and it’s working.
Question: can I search for an album inside a Folder as well?
For example I have a folder called “Promo Videos” and inside I have several albums such as “Instagram”, “TikTok”, etc.
Would I be able to check if those exist as well and send the files to those?
I tried something like “Promo Videos/TikTok”, but it just created an album with that name.
If that’s a big deal, no worries. I can work around what you just shared. This is already a great help! I can use the album with that name “Promo Videos - TikTok” for example.
Just curious to know if that’s possible and how. But again, if it’s too complex or something, no worries.
Truly appreciate your time and help!
@tiagorocha1979
This example after your last request.
- I have created folder with name Folder.
- Inside the folder named Folder I created subfolder with name subfolder
- Inside the subfolder I create album with the name Album 1
set {parentFolderName, subfolderName, albumName} to {"Folder", "Subfolder", "Album 1"}
set imagePathList to (choose file of type {"jpg", "jpeg", "tif", "tiff", "png", "gif"} with multiple selections allowed)
tell application "Photos"
set parentFolderNames to name of folders
if parentFolderName is in parentFolderNames then
set parentFolder to folder parentFolderName
end if
set subfolders to name of folders of parentFolder
if subfolderName is in subfolders then
tell folder subfolderName of folder parentFolderName
import imagePathList into album albumName
end tell
end if
end tell
I only do checking for Parent and Subfolder and if that is true, only then it will be imported to album.
Here is same as above with logs…
Ps. I have to do more tests I have not get make new album to work for subfolder.
set {parentFolderName, subfolderName, albumName} to {"Folder", "Subfolder", "Album 1"}
set imagePathList to (choose file of type {"jpg", "jpeg", "tif", "tiff", "png", "gif"} with multiple selections allowed)
tell application "Photos"
set parentFolderNames to name of folders
if parentFolderName is in parentFolderNames then
set parentFolder to folder parentFolderName
else
log parentFolderName & " do not exists"
end if
set subfolders to name of folders of parentFolder
if subfolderName is in subfolders then
tell folder subfolderName of folder parentFolderName
import imagePathList into album albumName
end tell
else
log subfolderName & " do not exists..."
end if
end tell
If you do not like to have check of parent folder or subfolder do exists.
The script become little more compact.
set imagePathList to (choose file of type {"jpg", "jpeg", "tif", "tiff", "png", "gif"} with multiple selections allowed)
importToAlbum(imagePathList, "Folder", "Subfolder", "Album 1")
on importToAlbum(imagePathList, parentFolderName, subfolderName, albumName)
tell application "Photos"
tell folder subfolderName of folder parentFolderName
import imagePathList into album albumName
end tell
end tell
end importToAlbum
Here is a picture how it looks in Photos.app
Here is example how you could male Parent, Subfolder and Album
makeAlbumInSubfolder("Parent", "Subfolder", "Album 1")
on makeAlbumInSubfolder(parentName, subfolderName, albumName)
tell application "Photos"
make new folder named parentName
make new folder named subfolderName at folder parentName
make new album named albumName at folder subfolderName of folder parentName
end tell
end makeAlbumInSubfolder
Yes, I think I will use this as a template for what I need at the moment, because I have some folders and albums created.
I will save all the other options here on my Notes so I can alway go back to them and learn something else.
Thank you so much for your time and help. Really precious!
This will save me so much time and energy when I adapt it to Keyboard Maestro!
@tiagorocha1979
If you have a complex subtree of folders you could also do it like this.
The second parameter in the handler use AppleScript list to feed an subtree. The first paremeter in the list is the top level folder.
set imagePathList to (choose file of type {"jpg", "jpeg", "tif", "tiff", "png", "gif"} with multiple selections allowed)
importToAlbum(imagePathList, {"Parent", "Subfolder"}, "Album 1")
on importToAlbum(imagePathList, folderNameList, albumName)
tell application "Photos"
set subtree to folderNameList
set {parentName, subfolderName} to subtree
tell folder subfolderName of folder parentName
import imagePathList into album albumName
end tell
end tell
end importToAlbum