Mac與Windows PC pc最最不同之處之一是是程序程序。程序。。。。。程序。程序。,您您,您需要掛掛載載載載,然後磁盤磁盤磁盤磁盤映像,然後然後磁盤然後載然後掛掛掛掛掛掛掛掛,然後然後然後然後時間內部測試測試多個應用程序。
考慮一,這這這次我們將幾工作工作工作工作工作工作工作流程工作工作流程小小工作工作小小小小小流程個個個個簡潔簡潔小小小個個個個個簡潔簡潔小個小個小個個簡潔簡潔簡潔的的小在在的的在在在在在在在在在在在在在在可以彈出/卸載 和 只需單擊幾下即可刪除磁盤映像。
讓我們開始了解如何設置這些出色的 Automator 工作流程。
彈出 DMG 文件時自動刪除它們
步驟1: 打開Automator並選擇創建一個新文檔。從對話盒中顯示的可用文檔類型中,選擇服務。
第二步: 在右面板的頂部,確保分別從下拉菜單中選擇“無輸入”和“查找器”選項,以方便最終結果如下圖所示。
第三步: 接下來,在 Automator 的左側面板上,搜索運行 AppleScript 操作並將其拖到右側面板中。一個 AppleScript 窗口將顯示一些佔位符代碼。
刪除該代碼,而將以下代碼複製並粘貼到腳架中:
tell application "Finder"
set selection_list to selection
if (count selection_list)
display dialog ¬
"Please select a volume mounted from a disk image." with title ¬
"No Selection Found" with icon stop ¬
buttons ["OK"] 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 ["OK"] 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 ["OK"] 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文件拖到廢紙坑時自動彈出
正如中看到看到看到看到看到中中看到看到看到看到看到工作工作的相同相同相同,只實現相同相同,隻隻,因此是,因此因此因此因此因此因此您您每將次次將
以下是創建它的步驟。
步驟1: 在Automator中創建一個新文檔並從可用文檔類型中選擇文件夾操作。
第二步: 在右面板的頂部,從下面的拉菜單中選擇其他……。然後,在彈出的對話框中,輸入 ~/.Trash 以使用該文件夾。
第三步: 接下來,在左面板上,將運行 Shell Script 操作拖到右面板。 在出現的兩個下拉菜單中,分別選擇 /usr/bin/python 和作為參數。
步驟4: 將腳本框中的佔位符腳替換為以下腳本:
import string, os, sys
lines = os.popen("hdiutil info").readlines()
should_eject = False
for line in lines:
if line.startswith("image-alias"):
path = line.split(":")[1]
image_path = path.lstrip().rstrip()
if image_path in sys.argv:
should_eject = True
elif line.startswith("/dev/") and should_eject is True:
os.popen("hdiutil eject %s" % line.split()[0])
should_eject = False
elif line.startswith("###"):
should_eject = False
完成後,保存文件夾操作並退出Automator。 現在,無論何時掛載DMG文件,您只需要將其拖到廢紙簍,同時將其加載。
酷提示: 您還可以按照本教程末尾的說明為這些操作創建鍵盤快捷鍵。
你去吧。兩種不同的工作流程可以在你的Mac上啟動使用一項非常方便的功能。現在減下要做的就是選擇你認為更方便的一種。情緒最好的? ,您都會更多地了解Automator。 享受!