Skip to content

Instantly share code, notes, and snippets.

@zmarffy
Created November 8, 2020 20:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zmarffy/b0452b3159f648a0c245a8a95ae6b216 to your computer and use it in GitHub Desktop.
Save zmarffy/b0452b3159f648a0c245a8a95ae6b216 to your computer and use it in GitHub Desktop.
Change Date Added field for a track in macOS Catalina's Music library
set d to text returned of (display dialog "Enter a date in %m%d%Y format (example: 01122020 for January 12, 2020)" default answer "" buttons {"Cancel", "Continue"} default button "Continue")
set trackFileList to {}
tell application "Music"
repeat with t in selection
set trackInfo to {}
copy POSIX path of (get location of t) to the end of trackInfo
copy (get played count of t) to the end of trackInfo
copy trackInfo to the end of trackFileList
end repeat
delete selection
end tell
do shell script "date -f %m%d%Y " & quoted form of d with administrator privileges
tell application "Music"
repeat with t in trackFileList
set addedTrack to add item 1 of t
set played count of addedTrack to item 2 of t
end repeat
end tell
do shell script "sntp -sS time.apple.com" with administrator privileges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment