Last active
August 29, 2015 13:57
-
-
Save kowata/9756401 to your computer and use it in GitHub Desktop.
iTunesでアーティスト名に付くfeat.以下をトラック名に付記するAppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ============================== | |
-- Hip Hop のアーティスト名についた feat. を曲名に移すのが面倒くさい。 | |
-- というツイートを見て、そういえばいつも自分もそう思っていたな… | |
-- という事で、以前書いた一括処理の AppleScript を少しいじってみた。 | |
-- | |
-- つまり Run-D.M.C. feat. Aerosmith の Walk This Way を | |
-- Run-D.M.C. の Walk This Way [ feat. Aerosmith ] にする為の | |
-- AppleScriptです。 | |
-- | |
-- アーティスト名の "feat" 以降の文字列を抜き出して曲名の末尾に追加します。 | |
-- *一応、"feat" の替わりに任意の文字列を入れられるようにもしてますが、 | |
-- とりあえず ""(空)にしてます。 | |
-- ============================== | |
-- 設定 | |
set targetStr to " feat" | |
set replaceStr to "" | |
tell application "iTunes" | |
set theTracks to selection of front browser window | |
set theTracksRef to a reference to theTracks | |
--繰り返し | |
repeat with i from 1 to count of theTracksRef | |
set theTrack to item i of my theTracksRef | |
set theTrackName to name of theTrack | |
set theArtist to artist of theTrack | |
-- " feat"以降を抜き出し | |
set num to the offset of targetStr in theArtist | |
-- 以下 "feat" が見つかれば実行 | |
if num > 0 then | |
set len to the length of theArtist | |
set featArtistName to characters num thru len of theArtist as text | |
-- 文字列を置き換え | |
set dels to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to featArtistName | |
set nameList to text items of theArtist | |
set AppleScript's text item delimiters to replaceStr | |
set nameText to nameList as string | |
set AppleScript's text item delimiters to dels | |
set artist of theTrack to nameText | |
-- トラック名に抜き出した" feat"以降を追加(前後に [] 追加してます) | |
set name of theTrack to theTrackName & " [" & featArtistName & " ]" | |
end if | |
end repeat | |
display dialog "Complete!" | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment