11.7 C
New York
Sunday, April 19, 2026

music.app – Creating/populating a playlist wih AppleScript


I’ve a script that imports MP3 tracks and places their imported filenames right into a playlist.  Round 350 instances, I’ve dragged the m3u8 file into Music’s songs view after which set the equalizer on the entire information in it to “Spoken Phrase.”  I figured that doing this in AppleScript would save me about ten seconds for every of the 1400+ playlists to go, or 3.8 hours.

I’ve by no means carried out any AppleScript, so I believed Claude Sonnet might assist. Sadly, it has taken greater than ten hours of “do that,” “properly, possibly this,” and many others. to lastly inform Claude “You are fired!”  I suppose “he” is aware of much less about AppleScript than I do.

I ought to have come right here within the first place.  If anybody right here truly KNOWS sufficient to determine one thing that may work, please do.

The zsh script passes within the full absolute path of the playlist file and the title of the playlist.  The present script does create the playlist with the proper title, however fails so as to add the information.  The filenames within the playlist file are all appropriate—dragging within the playlist file some 350 instances has at all times labored.

The most recent error message is

/Customers/WGroleau/bin/Add_Playlist_Set_EQ.osa:748:771: execution error: Music obtained an error: file observe id 26302 of library playlist id 62 of supply id 61 doesn’t perceive the “add” message. (-1708)

My locale is “en_US.UTF-8” and that’s the encoding of the playlist file.

The most recent model of the script, that produced the above error, is

on run argv
-- Import bible playlist and set equalizer
-- Equalizer can't be set through ID3
-- argv handed in from zsh script "After"
--
-- # 2026 Apr 14  C S 4  Preliminary model
-- # 2026 Apr 14  伟思礼  Add this header
--
  set m3u8_path to merchandise 1 of argv
  set pname to merchandise 2 of argv
  set fileRef to open for entry POSIX file m3u8_path
  set trackList to learn fileRef as «class utf8» ¬
                   utilizing delimiter (ASCII character 13)
  shut entry fileRef
  inform utility "Music"
      make new playlist with properties {title: pname}
      repeat with fpath in trackList
        set fpathStr to fpath as string
        set t to some observe of library playlist 1 ¬
                 whose location is (POSIX file fpathStr as alias)
      add t to playlist pname
    finish repeat
  finish inform
finish run

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

0FansLike
0FollowersFollow
0SubscribersSubscribe
- Advertisement -spot_img

Latest Articles