アンドロイド

Macでdmgファイルを自動的に取り出し、削除する方法

目次:

Anonim

MacがWindows PCと最も異なる点の1つは、アプリケーションのインストールに関することです。 Macでは、ディスクイメージをマウントしてからアンマウントし、インストールが完了したら削除する必要があります。特に短時間で多くのアプリをテストする必要がある場合は、少々面倒な作業になる可能性があります。

そのことを考えて、今度はAutomatorを使ってあなたのMacに実装できる、いくつかの素晴らしい小さなワークフローを紹介します。 いずれを使っても、Macへのアプリのインストールが完了するたびに、数回クリックするだけでディスクイメージの取り出し/取り外しおよび削除ができます。

これらの素晴らしいAutomatorワークフローを設定する方法から始めましょう。

それらを取り出すとき自動的にDMGファイルを削除します

手順1: Automatorを開き、新しい文書を作成することを選択します。 ダイアログボックスに表示される利用可能なドキュメントタイプから、 サービスを 選択し ます 。

ステップ2:右パネルの一番上で、ドロップダウンメニューからそれぞれ 'no input' と 'Finder' のオプションを選択して、最終結果が下の図のようになるようにしてください。

ステップ3:次に、Automatorの左パネルで、 Run AppleScript アクションを探し、それを右パネルにドラッグします。 AppleScriptウィンドウにプレースホルダコードが表示されます。

そのコードを削除し、代わりに次のコードをスクリプトボックスにコピーして貼り付けます。

tell application "Finder"

set selection_list to selection

if (count selection_list) < 1 then

display dialog

"Please select a volume mounted from a disk image." with title

"No Selection Found" with icon stop

buttons default button 1

return

end if

set my_selection to item 1 of selection_list

set my_kind to kind of my_selection

set my_name to name of my_selection

if my_kind is not "Volume" then

display dialog

"Please select a volume mounted from a disk image file." with title

"Selection is not a Disk Image" with icon stop

buttons default button 1

return

end if

set volume_list to paragraphs of (do shell script "hdiutil info | grep ^/dev/disk | grep -o '/Volumes/.*'")

set source_list to paragraphs of (do shell script "hdiutil info | grep ^image'-'alias | grep -o '/.*'")

set match_found to false

repeat with v from 1 to (count volume_list)

if "/Volumes/" & my_name = item v of volume_list then

set match_found to true

exit repeat

end if

end repeat

if match_found is not equal to true then

display dialog

"The selected volume does not appear to be a Disk Image." with title

"Could not find Disk Image" with icon stop

buttons default button 1

return

else

set my_source to POSIX file (item v of source_list) as alias

move my_source to the trash

eject my_selection

--reveal my_source

end if

end tell

ステップ4:今このAutomatorサービスを保存し、覚えやすい名前を付けます。

それでは、同じ目的を達成する別のAutomatorワークフローを見てみましょう。

ゴミ箱にドラッグすると自動的にDMGファイルを取り出す

タイトルからわかるように、このAutomatorワークフローでは逆の目的を除けば同じ目的を達成できます。そのため、マウントされたDMGファイルをゴミ箱にドラッグするたびにこのメッセージを避けることができます。

ステップ2:右側パネルの上部で、ドロップダウンメニューから[その他…]を選択します。 次に、ポップアップ表示されるダイアログボックスで、 〜/.Trash と 入力 してそのフォルダを操作します。