Script to delete (from playlist and disk) the currently playing OsX Music (uTunes) song

Elvis Ciotti
Dec 13, 2021

open “Script Editor” and paste the following

on deleteTrack(trackName)
tell application "Music"
set theTrack to track named trackName of playlist "Library"
set songFile to location of theTrack
delete theTrack
end tell
tell application "Finder" to delete songFile
end deleteTrack
on run
tell application "Music"
set currentSong to name of current track
end tell

deleteTrack(currentSong)

tell application "Music"
play
end tell

end run

Save, then run by either clicking “Play” icon, or from the terminal

osascript /Users/yourname/path/to/deletePlayingSong.scpt

--

--

Elvis Ciotti

Software Contractor — Java, Spring, k8s, AWS, Javascript @ London - hire me at https://www.linkedin.com/in/elvisciotti