iTunesで特定の歌詞が含まれている曲の歌詞を削除する

まず特定の歌詞が含まれている曲を集めて1つのプレイリストにしたい。

普通に探すとたぶん以下のスクリプトが最初に見つかるだろう。

tell application "iTunes"
display dialog "歌詞の一部を入力してください" default answer "" buttons {"Cancel", "OK"} default button 2
copy the result as list to {text_returned, button_pressed}

set thePlaylist to make new playlist with properties {name:text_returned}
with timeout of 60000 seconds
duplicate (every track of playlist "洋楽" whose lyrics contains text_returned) to thePlaylist
end timeout
end tell

ところが上記スクリプトだとなぜかうまくいかない(ほんとは含まれているのに見つけてくれない)。

他のスクリプトを探すとhttp://aurelio.net/soft/itunes-search-in-lyrics/が見つかった。

スクリプトをダウンロードして眺めてみたが、どうやら

duplicate (every track of playlist “洋楽” whose lyrics contains text_returned) to thePlaylist

という方法ではだめらしい。

上記スクリプトでは

set {theLocations, theLyrics} to {location, lyrics} of file tracks of selectedPlaylist
repeat with i from 1 to (count of theLocations)
if userText is in item i of theLyrics then
add {item i of theLocations} to playlist resultsPlaylistName
end if
end repeat

となっている。

いったい何が原因なのかいまいち分からないが、これでうまくいった。

次に歌詞の削除だが、m4aファイルであればhttp://dougscripts.com/itunes/scripts/ss.php?sp=deletelyricsの’Delete Lyrics’で消せることができる。mp3とかだとなぜか消せないので、消したい曲を選択して”ID3 タグを変換” > ver 1.0を選択して変換し、再びID3 タグをver 2.4等に変換すると消すことができる。