Mac OS X でデスクトップに置いてあるアイコンが再起動後に以前と違う位置になってしまうことがある。ファイル自体が失われる分けではないので、物質的な損失はないが人によっては精神的なダメージがかなり大きかったりする。
というわけで、デスクトップのアイコンの場所を保存・復元する AppleScript を書いてみた(というか大昔に書いたものを現状に合わせて少しだけ修正しただけ)。
まずは保存する方:
set AppleScript's text item delimiters to ":" tell application "Finder" -- activate set num to count (items of desktop) set tt to "" repeat with i from 1 to num set itemName to name of item i of desktop set itemPos to desktop position of item i of desktop set tt to (tt & ({itemName} & itemPos) as string) & return end repeat end tell choose file name with prompt "保存先のファイルを指定:" set f_name to result open for access f_name with write permission write tt to f_name close access f_name
そして、復元する方。
choose file with prompt "デスクトップの並びを保存したファイルを指定: " set fname to result open for access fname try repeat read fname before ":" set itemName to result read fname before ":" set itemX to result read fname before return set itemY to result tell application "Finder" if exists item itemName of desktop then set desktop position of item itemName of desktop to {itemX, itemY} end if end tell end repeat on error errStr end try
それぞれを AppleScript Editor で、「ファイル」→「新規」で開いた空のウインドウに入力して、「ファイル」→「別名で保存…」でアプリケーションを指定して保存しておくといい。やってることは自明なので使い方も特に説明する必要はないと思う。
(2011-02-27) OS X 10.6 の AppleScript Editor でアプリケーション化したものを添付した。