I am trying to put together an AppleScript to select each photo in my album. I have a smart album set up for my wedding and an iphone taking pictures. As the photos are taken, they are sent via iCloud photo stream to this smart album. I am using this script to make a slideshow of all the new photos coming in. (I want it to loop once it gets to the end of the photos.
I tried just making a slideshow, but it doesn't include new photos as they come in.
Here is my script so far. The error I am getting is that it cannot "Select" the photo.
set source_album to "wedding photos"
tell application "Photos"
activate
repeat until frontmost
end repeat
set photos to media items in album source_album
set selected_photo to selection
log selected_photo
repeat with i from 1 to count (photos)
set selected_photo to item i of photos
log selected_photo
select selected_photo --ERROR HERE!
delay 3
end repeat
end tell
Thanks for looking and helping!
Related
I've been using an AppleScript to export photos in a Smart Album in Apple Photos for a while now. After upgrading to Catalina, it seems that my query for all albums no longer returns Smart Albums.
Specifically, I have a line that loads all albums like this:
tell Application Photos
set theseAlbums to every album
...
end tell
Previously, theseAlbums would contain regular and smart albums. After upgrading to Catalina, they only contain the regular (non-smart) ones.
Is there anything I can do to query for smart albums? I looked at the Photos Dictionary and didn't see anything. I also tried changing every album to every container with no luck.
Here's the code in context - a helper function that finds an album by name:
on getAlbumNamed(thisName)
tell application "Photos"
set theseAlbums to every album
repeat with i from 1 to the count of theseAlbums
set thisAlbum to item i of theseAlbums
if the name of thisAlbum is thisName then
return thisAlbum
end if
end repeat
end tell
end getAlbumNamed
Thanks in advance for any help.
I am writing an applescript to iterate thru all photo in the default album 'Photos'
Here is my script:
tell application "Photos"
activate
set alls = albums "Photos"
repeat with photo in alls
say photo.name
end repeat
end tell
Line 3. throws the following syntax error:
I am new to this language and I am unable to find an remedy to the incorrect syntax. Can any one point out what is amiss here?
If you refer to the dictionary it helps to understand how each element is contained by other elements. To get the photos of all albums you have to loop through the media items of every album. This will get the filename of each photo.
tell application "Photos"
activate
set alls to every album
repeat with photoAlbum in alls
set photos to every media item in photoAlbum
repeat with photo in photos
get filename of photo
end repeat
end repeat
end tell
I know that there are many commands in AppleScript for Spotify such as the simple playpause command, but how would I pull a playlist's information from Spotify, and paste it in a choose from list? I would like it to take all of the songs from wherever you're listening from, and paste them in a choose from list so you can choose which song you would like to listen to. Is this even possible? Can I do something similar?
Also, how would you enable/disable shuffling?
Additionally, is there a way to search Spotify through AppleScript?
I'm not sure if any of these are possible, and Google doesn't have any info on this right now. Does anyone know how to do this?
The Spotify AppleScript implementation does not have specific commands to get at playlist information -- it only exposes "current track" to get info about the currently-playing track and "next track" to play the next track. You can work around this limitation to build an AppleScript array containing all the tracks in a current playlist.
set trackNameList to {}
set trackIDList to {}
tell application "Spotify"
activate
set shuffling to false
set repeating to true
set sound volume to 0
if player state is not playing then
playpause
end if
set trackID to spotify url of current track
repeat while trackIDList does not contain trackID
set end of trackIDList to trackID
set end of trackNameList to name of current track
next track
delay 1 -- otherwise Spotify misbehaves
set trackID to spotify url of current track
end repeat
end tell
tell me to activate
set chosenNames to choose from list trackNameList without multiple selections allowed
set chosenName to (item 1 of chosenNames) as string
repeat with i from 1 to count of trackNameList
set itsName to (item i of trackNameList) as string
if itsName is chosenName then
exit repeat
end if
end repeat
set trackID to (item i of trackIDList) as string
tell application "Spotify"
activate
set sound volume to 100
play track trackID
end tell
There is no AppleScript support for searching in Spotify.
I have songs in iTunes on my MacBook pro that I have rated from one-start to five-star. When I open the songs in my DJ software, it doesn't show the ratings because iTunes doesn't write them to the ID3 tag, but just keeps it within iTunes.
I have figured out that I can read the rating by doing this:
tell application "iTunes"
set songRating to get rating of current track
end tell
return songRating
Also, I can get the location by doing this:
tell application "iTunes"
set songLocation to get location of current track
end tell
return songLocation
How do now use the file path that I have to write the rating into the ID3 tag of the file?
You could set the comment tag to the rating, that should be readable in a 3rd party app.
e.g,
tell application "iTunes"
set comment of the current track to "rating:" & (get rating of current track)
end tell
Ratings are percentage values, i.e, 2 stars == 40.
I'm trying to run an Applescript that will play a song in iTunes. The problem is I need the song to have a specific artist as well. Whenever I write some script that uses "artist" I get an error stating that artist could not be accessed.
tell application "iTunes"
activate
play track "My Song"
end tell
this code works to play a track but I also need to specify the artist so that a track with the same name isn't accidentally played. Any help is greatly appreciated.
Thanks,
Sam
Adjust as necessary.
tell application "iTunes"
set mySongs to every track of library playlist 1 whose artist is "Styx" and name is "boat on the river"
repeat with aSong in mySongs
play aSong
end repeat
end tell