Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lantrix/99db17c50d644508a05bab0d5ba9542d to your computer and use it in GitHub Desktop.
Save lantrix/99db17c50d644508a05bab0d5ba9542d to your computer and use it in GitHub Desktop.

Revisions

  1. @Kautenja Kautenja revised this gist Jan 28, 2020. No changes.
  2. @Kautenja Kautenja revised this gist Jan 28, 2020. No changes.
  3. @Kautenja Kautenja created this gist Jan 28, 2020.
    36 changes: 36 additions & 0 deletions refresh-music-selection.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    tell application "Music"
    -- get the selection
    set theSongs to selection
    end tell

    -- setup the progress bar
    set theSongCount to length of theSongs
    set progress total steps to theSongCount
    set progress completed steps to 0
    set progress description to "Refreshing Songs..."
    set progress additional description to "Preparing to process."

    -- iterate over the songs
    repeat with i from 1 to theSongCount
    set theSong to item i of theSongs
    -- Update the progress detail
    -- get the metadata about the song
    tell application "Music"
    set theArtist to artist of theSong
    set theName to name of theSong
    end tell
    -- update the progress bar with additional information
    set progress additional description to i & "/" & theSongCount & " - " & theArtist & " - " & theName
    -- reload the song metadata from disk
    tell application "Music"
    refresh theSong
    end tell
    -- update the progress bar status
    set progress completed steps to i
    end repeat

    -- Reset the progress information
    set progress total steps to 0
    set progress completed steps to 0
    set progress description to ""
    set progress additional description to ""