AppleScript名:iTunesライブラリのファイル種別集計 |
— Created 2016-11-02 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "iTunesLibrary" –http://piyocast.com/as/archives/4301 set library to current application’s ITLibrary’s libraryWithAPIVersion:"1.0" |error|:(missing value) if library is equal to missing value then return set playLists to library’s allPlaylists() set gArray to library’s allMediaItems()’s |kind| set aRes to countItemsByItsAppearance(gArray) of me –> {{theName:"AAC オーディオファイル", numberOfTimes:3273}, {theName:"MPEG オーディオファイル", numberOfTimes:1768}, {theName:"購入した AAC オーディオファイル", numberOfTimes:1299}, {theName:"保護された AAC オーディオファイル", numberOfTimes:1102}, {theName:missing value, numberOfTimes:331}, {theName:"保護された MPEG-4 オーディオストリーム", numberOfTimes:183}, {theName:"MPEG オーディオストリーム", numberOfTimes:71}, {theName:"Apple ロスレス・オーディオファイル", numberOfTimes:36}, {theName:"QuickTime ムービーファイル", numberOfTimes:35}, {theName:"保護されたブック", numberOfTimes:28}, {theName:"AIFF オーディオファイル", numberOfTimes:21}, {theName:"MPEG-4 ビデオファイル", numberOfTimes:17}, {theName:"着信音", numberOfTimes:17}, {theName:"保護された MPEG-4 ビデオファイル", numberOfTimes:14}, {theName:"PDF 書類", numberOfTimes:11}, {theName:"ブック", numberOfTimes:8}, {theName:"購入したブック", numberOfTimes:6}, {theName:"iPhone/iPod touch/iPad App", numberOfTimes:5}, {theName:"購入した MPEG-4 ビデオファイル", numberOfTimes:5}, {theName:"インターネットオーディオストリーム", numberOfTimes:3}, {theName:"WAV オーディオファイル", numberOfTimes:2}, {theName:"iTunes Extras", numberOfTimes:2}, {theName:"iPhone/iPod touch App", numberOfTimes:1}, {theName:"QuickTime ムービー URL", numberOfTimes:1}, {theName:"Purchased AAC audio file", numberOfTimes:1}} –出現回数で集計 on countItemsByItsAppearance(aList) set aSet to current application’s NSCountedSet’s alloc()’s initWithArray:aList set bArray to current application’s NSMutableArray’s array() set theEnumerator to aSet’s objectEnumerator() repeat set aValue to theEnumerator’s nextObject() if aValue is missing value then exit repeat bArray’s addObject:(current application’s NSDictionary’s dictionaryWithObjects:{aValue, (aSet’s countForObject:aValue)} forKeys:{"theName", "numberOfTimes"}) end repeat –出現回数(numberOfTimes)で降順ソート set theDesc to current application’s NSSortDescriptor’s sortDescriptorWithKey:"numberOfTimes" ascending:false bArray’s sortUsingDescriptors:{theDesc} return bArray as list end countItemsByItsAppearance |
(Visited 38 times, 1 visits today)