Using Alfred to append to a Playlist in Apple Notes
The Problem
I listen to about ten hours of music a day. Most days (except Friday) I am my own DJ for the entire day. When I am not listening to the radio, I generally listen to full albums.
At random times during the day, albums come to mind that I want to quickly store for later recall. I am currently storing this data in an Apple Note called “Playlist.”
The best solution I can come up with at the time is to use Alfred. As I started to tackle this problem, I realized that adding text to the top of an Apple Note does just that, adds the note to the top of the note, above the title. Digging around, there seems to be no other way to do this than to use AppleScript. Unfortunately, I never learned AppleScript, and really have no desire to spend any time learning it.
The solution
To create the script, I turned to ChatGPT. I have been a developer for more than 30 years, so I have a good grasp of what the solution would look like, I have no idea how to write it. I crafted a good enough prompt, and it hit it pretty close . I have definite ideas about using AI to generate source code, and I’ll talk about that in another entry.
This got me precisely what I needed, but kept me thinking about ways to create a better solution. More on that below..
Here’s what the solution does. Typing the following into Alfred:
playlist echo and the bunnymen
Inserts something like:
2025-05-20 21:00:11
echo and the bunnymen
At the top of the Playlist Note.
That’s it!
Although this is a tiny bit of automation, it has allowed me to quickly brain dump without breaking stride on whatever I am working on. Being able to look at weeks of entries is also fun, and inspires album listens for weeks to come.
Some ideas for update
There are a few things I’d like to change for others who might want to use this script:
- The script should check if the Note exists. If it does not, it should be created.
- The script should allow the user to store the Playist Note wherever they want.
- For Super Bunda Points, the script should check for the album name in the album title, and insert a link to the album in that streaming service.
But for now, it has done a great job at doing what I need.
The AI generated AppleScript
Here is the source code generated.
on run(argv)
set inputText to item 1 of argv
set noteTitle to "Playlist" -- Your fixed note title
-- Get current date and time
set currentDateTime to (do shell script "date '+%Y-%m-%d %H:%M:%S'")
set stampedText to currentDateTime & "<br>" & inputText
tell application "Notes"
set theFolder to first folder whose name is "Notes"
set theNote to first note in theFolder whose name is noteTitle
set currentBody to the body of theNote
-- Split the current body into lines
set AppleScript's text item delimiters to "<br>"
set bodyLines to text items of currentBody
set AppleScript's text item delimiters to ""
-- Extract the title and the rest of the note
set noteTitleLine to item 1 of bodyLines
set remainingBody to ""
if (count of bodyLines) > 1 then
set AppleScript's text item delimiters to "<br>"
set remainingBody to (items 2 thru -1 of bodyLines) as string
set AppleScript's text item delimiters to ""
end if
-- Construct the updated body
set updatedBody to noteTitleLine & "<br><br>" & stampedText
if remainingBody is not "" then
set updatedBody to updatedBody & "<br><br>" & remainingBody
end if
set the body of theNote to updatedBody
end tell
end run
Links
- The Add to Playlist Plugin
- Alfred Gallery • Workflows • Play Song - This is a KILLER app to play songs much like the spotify mini player.
- Alfred Gallery • Workflows • Spotify Mini Player - The Spotify mini player mentioned above. Totally full featured and awesome.