Last active
August 29, 2015 14:06
-
-
Save mamemomonga/6aacce6761ecff1b166b to your computer and use it in GitHub Desktop.
iTunesで選択範囲のアルバムアーティストが空の場合、アーティストをアルバムアーティストとして設定する(OSX 10.9用)
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use 5.10.0; | |
binmode(STDOUT,':utf8'); | |
# -------------------------------------------------------------- | |
# iTunesで選択範囲のアルバムアーティストが空の場合 | |
# アーティストをアルバムアーティストとして設定する | |
# OSX 10.9用 | |
# -------------------------------------------------------------- | |
use Mac::AppleScript::Glue; | |
my $itunes = new Mac::AppleScript::Glue::Application('iTunes'); | |
foreach my $track(@{$itunes->selection}) { | |
# $track のエレメント・プロパティーは | |
# AppleScriptエディタ -> ライブラリ -> iTunes -> iTunes Suite -> [C] track | |
# で確認できる。 | |
local $@; | |
eval { | |
if($track->album_artist eq '') { | |
my $artist=ed($track->artist); | |
say $artist; | |
$track->set( album_artist => $artist ); | |
} | |
}; | |
if($@) { warn $@; } | |
} | |
sub ed { | |
my $buf=shift; utf8::decode($buf); return $buf; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment