Ich habe eine ziemlich große iTunes-Bibliothek (~ 300 GB), die hauptsächlich klassische Musik enthält. Ich mag das Work and Movement-Format sehr, aber leider ist es nicht praktikabel, meine Metadaten manuell auf das Work and Movement-Format zu aktualisieren. Fast alle vorhandenen Song-Tags haben das folgende Format:
Telemann - Concerto in E minor: I. Andante
II. Allegro
III. Largo
IV. Allegro
etc.
Ein Skript, das die Aktualisierung des Tagging-Systems automatisieren könnte, würde wie folgt aussehen.
Jede Hilfe oder Hinweise zur tatsächlichen Implementierung dieses Skripts wären sehr hilfreich. Ich habe mir Dougs Arbeits- und Bewegungsskripte angesehen und verwendet , aber sie decken nicht den Anpassungsprozess ab, der erforderlich wäre, um die römischen Ziffern von Anfang an zu löschen.
BEARBEITEN
Es hat sich herausgestellt, dass viele der Tags nicht das obige Format haben, sondern ein Format wie das folgende:
Serenade for strings in C major, Op. 48 - I. Allegro
Serenade for strings in C major, Op. 48 - II. Adagio
Serenade for strings in C major, Op. 48 - III. Allegro moderato
etc.
ODER im selben Format wie oben, außer dass arabische Ziffern anstelle der römischen Ziffern verwendet werden.
Das Skript sollte dazu führen, dass die „Bewegung“-Tags die folgenden Ausgaben haben:
Allegro
Adagio
Allegro moderato
Die Idee ist, ich würde den ersten Teil davon bekommen ("Serenade für Streicher in C-Dur, op. 48") und ihn in das "work"-Tag kopieren, das ich bereits implementiert habe, dann den restlichen Text holen und den Satz entfernen Nummern und weisen Sie es dem Tag Bewegung zu. Jede Hilfe bei der Implementierung eines Systems, das dies tun würde, wäre willkommen.
Hier ist das Skript in seiner aktuellen Form. Es basiert auf Dougs Name to Work-Skript.
tell application "iTunes"
set sel to selection of front browser window
if sel is {} then
try
display dialog "Nothing is selected…" buttons {"Quit"} with icon 0
end try
return
end if
set c to (count of sel)
set songName to (get name of item 1 of sel)
set userOptions to display dialog "Edit for Work name and then click OK." default answer songName --prompt for work name
repeat with i from 1 to c --set the movement numbers
set thisTrack to item i of sel
try
set work of thisTrack to text returned of userOptions
set movement number of thisTrack to i
set movement count of thisTrack to c
set movement of thisTrack to my delRomNum(name of thisTrack) -- copy movement text from song name and delete roman numerals
end try
end repeat
end tell
on delRomNum(t) -- the perl command search and delete any roman numeral (must be a word followed by the period and a space character)
do shell script "/usr/bin/perl -pe 's/\\b[IVXLCDM]+\\b. //g' <<< " & quoted form of t
end delRomNum
Um die römischen Ziffern zu löschen, können Sie den delRomNum()
Handler aus diesem Skript verwenden:
--- this text as an example.
set movementText to "Telemann - Concerto in E minor: I. Andante
II. Allegro
III. Largo
IV. Allegro
etc."
set movementText to my delRomNum(movementText) -- delete roman numerals
on delRomNum(t) -- the perl command search and delete any roman numeral (must be a word followed by the period and a space character)
do shell script "/usr/bin/perl -pe 's/\\b[IVXLCDM]+\\b. //g' <<< " & quoted form of t
end delRomNum
Das Ergebnis des Skripts ist
"Telemann - Concerto in E minor: Andante
Allegro
Largo
Allegro
etc."
Aktualisieren:
Wenn ich das richtig verstanden habe:
Aus jeder Zeile in einer Zeichenfolge muss der Befehl die Zeichen vom Anfang der Zeile bis zum ersten Vorkommen von (einer römischen Zahl oder einer arabischen Zahl) gefolgt von dem Punkt und einem Leerzeichen löschen, also verwenden Sie diesen Handler:
-- call it, like this --> set movement of thisTrack to my delRomNum(name of thisTrack)
on delRomNum(t)
(*** from the contents of the 't' variable (the end of lines must be an Unix Line Endings), so the 'tr' command change the carriage returns (Mac Line Endings) to linefeed (Unix Line Endings)
the 'perl' command delete the first character in each line through the first occurrence of a word which contains (a roman numeral or a number) followed by the period and a space character ***)
do shell script "tr '\\r' '\\n' <<< " & (quoted form of t) & " | /usr/bin/perl -pe 's/^.*?\\b[IVXLCDM0-9]+\\b. //g'"
end delRomNum
Beispiel: Das Skript übergibt diesen String als Parameter an den Handler
Serenade for strings in C major, Op. 48 - I. Allegro
Serenade for strings in C major, Op. 48 - II. Adagio
Serenade for strings in C major, Op. 48 - III. Allegro moderato
Serenade for strings in C major, Op. 48 - 4. Allegro Molto Appassionato
Serenade for strings in C major, Op. 48 - 5. Adagio - Allegro Molto
Serenade for strings in C major, Op. 48 - 6. Allegro moderato
VII. Adagio - Allegro Non Troppo
8. Allegro Ma Non Tanto
9. Largo
Adagio
etc.
Der Handler gibt zurück:
Allegro
Adagio
Allegro moderato
Allegro Molto Appassionato
Adagio - Allegro Molto
Allegro moderato
Adagio - Allegro Non Troppo
Allegro Ma Non Tanto
Largo
Adagio
etc.
Nun, ich habe das selbst herausgefunden. Für den Fall, dass dies für jemand anderen hilfreich ist, ist dies das vollständige Skript.
tell application "iTunes"
set sel to selection of front browser window
if sel is {} then
try
display dialog "Nothing is selected…" buttons {"Quit"} with icon 0
end try
return
end if
set c to (count of sel)
set songName to (get name of item 1 of sel)
set workName to display dialog "Edit for Work name and then click OK." default answer songName --prompt for work name
set movementLength to display dialog "Edit to everything except the movement name. Do not include the roman numeral if one is present. If an arabic numeral is present, include it." default answer songName --prompt for movement length
repeat with i from 1 to c --set the movement numbers
set thisTrack to item i of sel
set songName to (get name of thisTrack)
set work of thisTrack to text returned of workName
set movement number of thisTrack to i
set movement count of thisTrack to c
set movement of thisTrack to my delRomNum(text ((length of text returned of movementLength) + 1) thru (length of songName) of songName as string) -- copy movement text from song name and delete roman numerals
end repeat
end tell
on delRomNum(t) -- the perl command search and delete any roman numeral (must be a word followed by the period and a space character)
do shell script "/usr/bin/perl -pe 's/\\b[IVXLCDM]+\\b. //g' <<< " & quoted form of t
end delRomNum
Willem Hill
Willem Hill
Benutzer3439894
Willem Hill