AppleScript: Länge einer Audio-Datei auslesen

Spotlight kann so etwas wunderbar und noch dazu bei verschiedensten Audio-Formaten:

Code zum markieren einmal anklicken Code im Skript-Editor öffnen

set aFile to choose file

tell application “Finder” to set filename to name of aFile

set AppleScript‘s text item delimiters to ” = “

set duration to text item 2 of (do shell script “mdls -name kMDItemDurationSeconds ” & quoted form of (POSIX path of aFile))

set AppleScript‘s text item delimiters to “.”

set total_seconds to text item 1 of duration

set AppleScript‘s text item delimiters to “”

set showsec to (total_seconds as integer) mod 60

set showmin to (total_seconds as integer) div 60

display dialog filename & return & return & “Duration:” & return & showmin & “ min ” & showsec & ” sec”