Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/6aacce6761ecff1b166b to your computer and use it in GitHub Desktop.
Save mamemomonga/6aacce6761ecff1b166b to your computer and use it in GitHub Desktop.
iTunesで選択範囲のアルバムアーティストが空の場合、アーティストをアルバムアーティストとして設定する(OSX 10.9用)
#!/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