2012-05-11 4 views

答えて

6

OS Xマシンに接続する外付けドライブは、/Volumesにマウントされています。そのフォルダーで変更を監視する場合は、追加された外部ドライブをピックアップして処理できます。このコードを実行:

property ignoredVolumes : {"Macintosh HD", "Time Machine Backups"} -- add as needed 
tell application "System Events" 
    set rootVolume to disk item (POSIX file "/Volumes" as text) 
    set allVolumes to name of every disk item of rootVolume 
    repeat with aVolume in allVolumes 
     if aVolume is not in ignoredVolumes then 
      set name of disk item (path of rootVolume & aVolume) to newName 
     end if 
    end repeat 
end tell 

があなたのignoredVolumesリストに含まれていないドライブの名前を変更しますnewNameに(すべてが、あなたは、無視ターミナルでls /Volumesを実行して、プロパティに名前を追加したいものをを外してください)。

property pollIntervall : 60 -- in seconds 
property ignoredVolumes : {…} -- from above 

on run 
    my checkVolumes() 
end run 

on idle 
    my checkVolumes() 
    return pollInterval 
end idle 

on checkVolumes() 
    tell … end tell -- from above 
end checkVolumes 

のAppleScriptエディタ(あなたが行うときは、「滞在開く」ダニを確認して、「AppleScriptのアプリケーション」を選択)に保存します。これはすべての変更でトリガさせるには、Stay-Open script applicationようにコードを修正。起動されると、スクリプトは実行され続け、pollInterval秒ごとにon idleハンドラを実行します。

これは基本的にonce-in-a-whileバッチジョブを実行している場合に問題ありません。あなたが滞在-開いているスクリプトのアプリケーションを実行しているに依存しない、より恒久的な解決策が必要な場合は、どちらか

  • Philip Regan on Ask Differentから/Volumesフォルダ(帽子の先端にフォルダアクションスクリプトを添付することができ、設定する方法の詳細については、 this Mac OS X Hints postでアクション) - 利点はあなたの厳密プロセス/Volumesへの追加、またはtrueに設定StartOnMountキーでLaunchAgentを作成することで
  • 使用launchdている - エージェントは(ファイルシステムがマウントされるたびに起動するスクリプト/アプリをトリガーします帽子の先端はDaniel Beck at Ask Differentに;詳細はApple’s Technical Note TN2083を参照)。
関連する問題