選択した項目に追加しましょう

拡張子で選択ができれば、やっぱり選択した項目に追加ができれば良いなと思ったりして…結局、もう一つのAppleScriptが誕生。

tell application "Finder"
  activate
  try
    display dialog "Extension:" default answer "" ¬
        buttons {"Cancel", "Extend"} default button 2
    copy the result as list to {fileExtension, confirmSelection}
    if confirmSelection is equal to "Extend" then
      set itemList to items of target of front window
      set selectedItem to the selection
      set currentFolder to target of front window as text
      set itemText to selectedItem as text
      if itemText is equal to currentFolder then
        set selectedItem to {}
      end if
      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

これで全部完璧だ。Finderで選択したファイルに設定したファイルを追加される。問題は一つだね。最近、自分で作ったシステムレベルのショートカットキーがいっぱいあり過ぎて、覚えやすいキーが大体使われていた。他のアプリケーションにぶつからないようにキーをアサインしないと…全部キーで操作している人もたまには困るよね。