Copie BPM y calificación de estrellas a los comentarios en itunes usando Applescript

Quiero un applescript para obtener el BPM y la calificación de estrellas de un grupo seleccionado de MP3 y pegar la información en la sección de comentarios.

Encontré este código que copiará la calificación de estrellas de una pista a la vez, pero no conozco Applescript lo suficientemente bien como para modificarlo para hacer un grupo de pistas seleccionadas y también tomar el 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
De hecho, descubrí cómo editar un script para obtener el BPM. Ahora solo necesito hacer que este script pueda editar una selección.

Respuestas (1)

Desea tomar la selección, que será una lista de pistas. Luego, usa un bloque de repetición para procesar cada pista en la lista. Aquí está el guión. Es posible que desee agregar comprobaciones para asegurarse de que iTunes se está ejecutando y algunos bloques de prueba en caso de fallas:

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