http://mac.appstorm....th-applescript/
Mi sono detto che a partire da uno degli script esistenti, questo, si poteva crearne uno che trasformasse le maiuscole in minuscole: in italiano (tra le altre lingue) sostantivi e verbi non hanno diritto alla maiuscola più che non in una frase normale. Mi sono detto che sarebbe stato facile introdurre questo minimo cambiamento, eppure, come diceva kkk, non è così semplice (soprattutto quando non si è capaci).
Vorrei copiare solo la parte utile, ma non sono sicuro di quale sia, quindi copio tutto.
--===========LIST OF TAGS TO MODIFY===========--
--These are the tags that will be selected by default.
property my_tags_to_modify : {"name", "album"}
--This is the complete list of tags -->which you shouldn't modify unless you know what you are doing 8>)
property tags_to_modify : {"name", "album", "artist", "composer", "grouping", "show"}
--===========LIST OF LOWERCASE WORDS===========--
--These are the words that will remain lowercase, unless they begin or end the title.
property lowercase_words : {"a", "an", "and", "at", "but", "by", "for", "in", "nor", "of", "on", "or", "so", "the", "to", "with"}
--Feel free to add these: "amid", "anti", "as", "down", "into", "like", "near", "off", "onto", "out", "over", "past", "per", "plus", "save", "some", "than", "till", "up", "upon", "via", "yet"
--===========LIST OF UNMODIFIED WORDS===========--
--These are the words that won't be modified at all. It's a good place to put all-uppercase words.
property unmodified_words : {"FM", "USA", "WDPK", "OYF’N", "UR", "TV", "MGM", "DVD", "ABC", "CD", "USSR", "CA", "WA", "NY", "NYC", "LP", "EP", "VHS", "UK", "GB", "'Bout", "'Cause", "o'", "'n'", "n'", "McCartney", "vs.", "de", "feat.", "Pi-hsien", "von", "van"}
--===========LIST OF TRAILING CHARACTERS===========--
--Any word trailed by a character in this list will be title cased. (ie. "a song" (with a remix) -> "A Song" (With a Remix))
property other_chars : "_!\"$%&/()=¿?@¡|#¢∞“”[]{}*-+•«»—´`ºª…:;."
--===========NO NEWBIE-USER-MODIFIABLE PARTS BELOW===========--
property lowercase_match : false
property unmodified_Match : false
property other_chars_match : false
property my_tags : my_tags_to_modify
property myTitle : "Proper English Title Capitalization"
global aWord, newWord
tell application "iTunes"
set mySelectedTracks to selection
if mySelectedTracks is not {} then
set old_fi to fixed indexing
set fixed indexing to true
set songs_selected to (count mySelectedTracks)
if songs_selected = 1 then
set songs_selected_message to "Brani selezionati: " & songs_selected & "." as text
else
set songs_selected_message to "Brani selezionati: " & songs_selected & "." as text
end if
set choice to button returned of (display dialog songs_selected_message & return & return & "Che facciamo?" buttons {"Lascia stare", "Configura…", "Modifica"} default button 3 with icon 1 with title myTitle)
if choice = "Configura…" then
set my_tags_to_modify to (choose from list tags_to_modify with prompt "Scegli gli attributi che vuoi modificare (quelli non selezionati verranno ignorati tags will be ignored):" default items my_tags_to_modify with title myTitle with multiple selections allowed without empty selection allowed)
if my_tags_to_modify is false then
set my_tags_to_modify to my_tags
run me
else
display dialog "Possiamo andare." buttons {"Lascia stare", "Modifica"} default button 2 with title myTitle
end if
end if
repeat with selected_tag in my_tags_to_modify --Check which tags are to be modified.
repeat with aTrack in mySelectedTracks
set selected_tag to selected_tag as text
if selected_tag = "name" then set theTitle_as_List to (my text_to_list(aTrack's name, space))
if selected_tag = "artist" then set theTitle_as_List to (my text_to_list(aTrack's artist, space))
if selected_tag = "composer" then set theTitle_as_List to (my text_to_list(aTrack's composer, space))
if selected_tag = "album" then set theTitle_as_List to (my text_to_list(aTrack's album, space))
if selected_tag = "show" then set theTitle_as_List to (my text_to_list(aTrack's show, space))
if selected_tag = "grouping" then set theTitle_as_List to (my text_to_list(aTrack's grouping, space))
set newTitle to {}
set last_item to (count theTitle_as_List)
set word_counter to 1
repeat with aWord in theTitle_as_List
set newWord to ""
repeat with my_unmodified_Match in unmodified_words
--Check if any of the words belong to the list of unmodified words.
if (my_unmodified_Match as text) = (aWord as text) then
set unmodified_Match to true
exit repeat
end if
end repeat
if unmodified_Match then
--Unmodify matching words in unmodified_words list (actually just copy the word from the list).
set newWord to my_unmodified_Match as text
set unmodified_Match to false
else if (word_counter = 1) then
--Capitalize first word in title.
my SetCase(aWord)
else
--For words not beginning or ending the title (middle words).
repeat with my_lowercase_Match in lowercase_words
--Check if any of the middle words belong to the list of lowerase words.
if (my_lowercase_Match as text) = (aWord as text) then
set lowercase_match to true
exit repeat
end if
end repeat
if lowercase_match then
--Lowercase matching words in lowercase_words list (actually just copy the word from the list).
set newWord to my_lowercase_Match as text
set lowercase_match to false
else
--Capitalize the rest of the words.
my SetCase(aWord)
end if
end if
copy newWord to end of newTitle
set word_counter to (word_counter + 1)
end repeat
-->> log (my list_to_text(newTitle, space)) -- de-bugging only
try
if selected_tag = "name" then set aTrack's name to my list_to_text(newTitle, space)
if selected_tag = "artist" then set aTrack's artist to my list_to_text(newTitle, space)
if selected_tag = "composer" then set aTrack's composer to my list_to_text(newTitle, space)
if selected_tag = "album" then set aTrack's album to my list_to_text(newTitle, space)
if selected_tag = "show" then set aTrack's show to my list_to_text(newTitle, space)
if selected_tag = "grouping" then set aTrack's grouping to my list_to_text(newTitle, space)
end try
end repeat
end repeat
copy old_fi to fixed indexing
display dialog return & return & "Tutto fatto!" buttons {"Bene"} default button 1 with icon 1 with title myTitle giving up after 5
else
display dialog "Non hai selezionato alcun brano." buttons {"Lascia stare"} default button 1 with icon 0
end if
end tell
--The handler taking care of the casing of words.
on SetCase(aWord)
repeat with j from 1 to (length of aWord)
if other_chars contains (character j of aWord) then
set j to (character j of aWord)
set newWord to newWord & j
set other_chars_match to true
else if other_chars_match then
set j to (character j of aWord)
if ((id of j) is greater than 96) and ((id of j) is less than 123) then
set newWord to newWord & (character id ((id of j) - 32))
else if ((id of j) is greater than 64) and ((id of j) is less than 91) then
set newWord to newWord & j
else
set newWord to newWord & j
end if
set other_chars_match to false
else if (j = 1) then
set j to (character j of aWord)
if ((id of j) is greater than 96) and ((id of j) is less than 123) then
set newWord to newWord & (character id ((id of j) - 32))
else
set newWord to newWord & j
end if
else
set j to (character j of aWord)
if ((id of j) is greater than 96) and ((id of j) is less than 123) then
set newWord to newWord & j
else if ((id of j) is greater than 64) and ((id of j) is less than 91) then
set x to (character id ((id of j) + 32))
set newWord to newWord & x
else
set newWord to newWord & j
end if
end if
end repeat
end SetCase
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
on list_to_text(theList, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set txt to theList as text
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (txt)
end list_to_text
Se qualcuno perde un po' del suo tempo per risolvere l'inghippo mi fa un gran favore!
D












