旧MacOSで作成したファイルに拡張子を追加するために作成したAppleScript。手作業でFinderから拡張子を追加すると確認ダイアログが出て、ちょっとウザかったので作成。簡単なスクリプトなのに何故か手間がかかってたり。
使い方は、Finderでファイルを選択して右クリック。サービス・メニューから「拡張子を設定」を選択して、出て来たリスト選択ダイアログから拡張子を選択するだけ。
しかし、OSXの問題なのだろうかリスト選択ダイアログ(choose from list)がデスクトップの最前面に出て来ない。
いろいろ調べてみると、サービス(というかワークフロー)は「Automator Runner」プロセスで動作している模様。
これをactivateすることで前面に呼び出す事ができます。AppleScriptと違って、ワークフローはブログに公開しづらいですね。
拡張子を設定のワークフローのスクリーンショット
アクションのソースコード
property extList : {"jpg", "png", "zip", "txt", "html"}
on run {input, parameters}
tell application "Automator Runner"
activate
set chooseList to choose from listextListwith title "拡張子を選択"
end tell
activate
if chooseList is false then
return input
end if
set theExt to item 1 of chooseList
repeat with theItem in input
set theFileInfo to info fortheItem
if (folder of theFileInfo) is true then
--folder
else
--item
tell application "Finder"
set name extension of filetheItem to theExt
end tell
end if
end repeat
return input
end run
実行環境
Automator 2.4/Apple/iMac10,1/OSX 10.9.2