Question:
I'm trying to use AppleScript to automatically set the start and stop times for selected tracks in the macOS Music app. While the start time is correctly set to 10 seconds, the stop time (finish) does not get applied.
Here’s the code I’m using:
tell application "Music"
set selectedTracks to selection
repeat with aTrack in selectedTracks
set trackDuration to (duration of aTrack) / 1000 -- Duration in seconds
set start of aTrack to 10.0 -- Set start time to 10 seconds
set finish of aTrack to (trackDuration - 10.0) -- Set stop time 10 seconds before the end
end repeat
end tell
The issue is that the start time gets set correctly, but the stop time does not change and the "Stop" checkbox is not checked in the Options tab of the track info. How can I correctly set the stop time and ensure the checkbox is activated?
Any help or advice would be appreciated!
I am a beginner und have used ChatGPT. I work on macOS 15.0 Sequoia Beta, Music 1.5.0.174
trackDuration
, it's calledduration
(which is what your script uses, but wrongly).trackDuration
in your script is actually a variable… which you are setting with theset
command. You could call it anything and the result would still be the same. Think seconds.