指定UTIでUTIを入れたリストをフィルタリング

AppleScript名:指定UTIでUTIを入れたリストをフィルタリング
— Created 2017-11-03 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

set aList to {"public.jpeg", "com.compuserve.gif", "public.svg-image", "public.plain-text", "com.apple.iwork.keynote.key", "com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.microsoft.word.doc", "com.microsoft.excel.xls", "com.microsoft.powerpoint.ppt", "com.apple.mail.email", "com.apple.applescript.script", "com.apple.applescript.text", "public.html", "com.apple.property-list", "public.zip-archive", "public.au-audio", "com.apple.m4a-audio", "com.apple.m4v-video"}

set aRes to filterUTIList(aList, "public.text")
–>  {​​​​​"public.plain-text", ​​​​​"com.apple.applescript.script", ​​​​​"com.apple.applescript.text", ​​​​​"public.html"​​​}

set bRes to filterUTIList(aList, "public.image")
–>  {​​​​​"public.jpeg", ​​​​​"com.compuserve.gif", ​​​​​"public.svg-image"​​​}

set cRes to filterUTIList(aList, "public.audiovisual-content")
–>  {​​​​​"public.au-audio", ​​​​​"com.apple.m4a-audio", ​​​​​"com.apple.m4v-video"​​​}

on filterUTIList(aUTIList, aUTIstr)
  set anArray to NSArray’s arrayWithArray:aUTIList
  
set aPred to NSPredicate’s predicateWithFormat_("SELF UTI-CONFORMS-TO %@", aUTIstr)
  
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
  
return bRes
end filterUTIList

★Click Here to Open This Script 

Please follow and like us:

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です