- Code: Select all
if application "Music" is running then
delay 3.0
tell application "Music" to quit
end if
When I run it in Script Editor, it does exactly what I want (I delay for 3 seconds in case it takes longer for the import to happen. Just a hacky failsafe.) When I run it with Hazel I see this in the log (and Music doesn't close):
- Code: Select all
2024-11-03 09:30:56.943 hazelworker[1763] Sixpence None the Richer: Rule Run on sub-folders matched.
2024-11-03 09:30:56.948 hazelworker[1763] 13 There She Goes.mp3: Rule Import new music matched.
2024-11-03 09:30:57.145 hazelworker[1763] /Users/fuser/Music/Media.localized/Sixpence None The Richer/Sixpence None the Richer/13 There She Goes.mp3 added to Music playlist Library
2024-11-03 09:30:57.225 hazelworker[1763] [Error] AppleScript failed: Error executing AppleScript on file /Users/fuser/Music/Media.localized/Sixpence None The Richer/Sixpence None the Richer/13 There She Goes.mp3.
2024-11-03 09:30:57.226 hazelworker[1763] OSAScript error: {
NSLocalizedDescription = "Music got an error: Can\U2019t get \U00abclass RUNG\U00bb.";
NSLocalizedFailureReason = "Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,69069 \"Music\"]>";
OSAScriptErrorAppNameKey = Music;
OSAScriptErrorBriefMessageKey = "Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorMessageKey = "Music got an error: Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorNumberKey = "-1728";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'obj '{ 'form':'prop', 'want':'prop', 'seld':'RUNG', 'from':null() }>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
2024-11-03 09:30:57.229 hazelworker[1763] 04 Kiss Me.mp3: Rule Import new music matched.
2024-11-03 09:30:57.262 hazelworker[1763] /Users/fuser/Music/Media.localized/Sixpence None The Richer/Sixpence None the Richer/04 Kiss Me.mp3 added to Music playlist Library
2024-11-03 09:30:57.269 hazelworker[1763] [Error] AppleScript failed: Error executing AppleScript on file /Users/fuser/Music/Media.localized/Sixpence None The Richer/Sixpence None the Richer/04 Kiss Me.mp3.
2024-11-03 09:30:57.270 hazelworker[1763] OSAScript error: {
NSLocalizedDescription = "Music got an error: Can\U2019t get \U00abclass RUNG\U00bb.";
NSLocalizedFailureReason = "Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,69069 \"Music\"]>";
OSAScriptErrorAppNameKey = Music;
OSAScriptErrorBriefMessageKey = "Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorMessageKey = "Music got an error: Can\U2019t get \U00abclass RUNG\U00bb.";
OSAScriptErrorNumberKey = "-1728";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'obj '{ 'form':'prop', 'want':'prop', 'seld':'RUNG', 'from':null() }>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
Thanks!