May 13 '12 - 9:40 am

Project: Gather Partially Played Tracks

I got an email from Correspondent Sherwood Botsford asking if there was any way to round up his partially played audiobooks. What he wanted to do was maintain a playlist of recently added audiobook tracks that he hadn’t finished listening to and sync it to his iPhone. He’d gotten the recently added stuff okay by using a Smart Playlist. But Smart Playlists don’t include any criteria for detecting how far along a track has been played, and Last Skipped may not necessarily have been set if a track was simply stopped rather than skipped.

If a track’s “Remember playback position” setting in its Get Info’s Options tab has been checkmarked—presumably, your audiobooks are “bookmarkable” by default or you have set the “remember” option manually—a track’s bookmark property will contain the number of seconds the track had been played before it was stopped. Thus, if any tracks have a bookmark value greater than zero then they’ve been partially played.

So here’s a script that will gather all those partially played tracks into a new playlist named “Partially Played” and that playlist can be the source for the Smart Playlist:

property nameOfPlaylist : “Partially Played”

tell application “iTunes”

set opt to button returned of (display dialog ¬

“Find partially played tracks in:” buttons ¬

{”Cancel”, “Entire Library”, “Books”} default button 3)

if opt is “books” then

set targetLibrary to (some playlist whose special kind is Books)

else

set targetLibrary to library playlist 1

end if

try

set thePlaylist to some playlist whose name is nameOfPlaylist

on error

set thePlaylist to (make playlist with properties {name:nameOfPlaylist})

end try

try

delete every track of thePlaylist

end try

duplicate (every track of targetLibrary whose bookmark > 0) to thePlaylist

reveal thePlaylist

end tell

It will take a few seconds to run on a very large library. So I’ve provided an option to look at either all the tracks in the library or just those in the “Books” library and set the targetLibrary variable to this choice. Then, it will try to set the variable thePlaylist to a playlist named “Partially Played”. If it errors because the “Partially Played” playlist doesn’t exist yet it will set thePlaylist to a new “Partially Played” playlist. Then it will try to remove all the tracks in it (in order to update a previously rounded-up batch). Finally it will find all the tracks in the targetLibrary with a bookmark greater than 0 and copy them to the “Partially Played” playlist.

Site contents © 2001 - 2014 (that's right: 2001) Doug Adams and weblished by Doug Adams, dougscripts AT mac DOT com. About.
All rights reserved. Legal.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc.