使用Applescript将BPM和星级评级复制到iTunes中的评论


2

我想要一个AppleScript来获取所选MP3组的BPM和星级,并将信息粘贴到评论部分。

我发现这个代码可以一次复制一个轨道的星级,但我不知道它足以修改它来做一组选定的轨道并抓住BPM。

tell application "iTunes"
    set theTrack to (item 1 of (get selection))
    set theRating to rating of theTrack
    if theRating = 100 then
        set comment of theTrack to "5 Star"
    else if theRating  80 then
        set comment of theTrack to "4 Star"
    else if theRating  60 then
        set comment of theTrack to "3 Star"
    else if theRating  40 then
        set comment of theTrack to "2 Star"
    else if theRating  20 then
        set comment of theTrack to "1 Star"
    else if theRating = 0 then
        set comment of theTrack to "0 Star"
    end if
end tell

我实际上想出了如何编辑脚本来获取BPM。现在我只需要让这个脚本能够编辑选择。
祝福2015年

Answers:


1

您想要获取选择,这将是一个轨道列表。然后,使用重复块处理列表中的每个轨道。这是脚本。您可能希望添加检查以确保iTunes正在运行,并在发生故障时尝试阻止:

tell application "iTunes"
    set selectedTracks to selection
    repeat with thisTrack in selectedTracks
        set theRating to rating of thisTrack
        set theBPM to bpm of thisTrack
        set theComment to "" & (theRating / 20 as integer) & " star | BPM: " & theBPM
        set comment of thisTrack to theComment
    end repeat
end tell
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.