拡張子で選択しましょう
iBookでプログラムを書く時に、同じ拡張子のファイルを選択したかったら、面倒だね。一つの方法は拡張子でソートして、その拡張子を選択する。うぅ、多段階の作業…他の方法は、コマンドキーを押しながら選択する。ファイルが多かったら、どうするの?うぅ、やっぱり使えない。
こういう作業は人間がやるよりも、スクリプトでやった方が良いだね。そのせいで、このようなAppleScriptが誕生。
tell application "Finder" activate try display dialog "Extension:" default answer "" ¬ buttons {"Cancel", "Select"} default button 2 copy the result as list to {fileExtension, confirmSelection} if confirmSelection is equal to "Select" then set itemList to items of target of front window set selectedItem to {} repeat with ii from 1 to number of items in itemList set currentItem to item ii of the itemList if the name extension of the currentItem is ¬ equal to fileExtension then set selectedItem to {currentItem} & selectedItem end if end repeat select selectedItem end if on error beep 3 end try end tell
これで、選択は簡単で便利になった。スクリプトを実行して、拡張子を記入すれば、勝手に選択される。最後に、Sparkに登録すれば、ショートカットキーでスクリプトを実効することがができる。こんな便利な物は何で昔考えてなかったのだろう?