好的,明白了。您可以使用下面給出的的Automator工作流內像這樣的AppleScript:
每選擇文件中查找,如果它的擴展名是ext_list
,它會被移動到回收站,等等將在同一文件夾中具有相同名稱的所有其他文件的擴展名是also_these_extensions
中的那些文件。
它可能是有用的,例如,也用於清洗輔助LaTeX文件的文件夾:只需將"tex"
分成ext_list
和所有其他分機(如"aux", "dvi", "log"
)分成also_these_extensions
。
所選文件不需要位於同一文件夾內;您也可以在Spotlight搜索結果窗口中選擇多個項目。
on run {input, parameters}
-- for every item having one of these extensions:
set ext_list to {"dng"}
-- also process items with same name but these extensions:
set other_ext_list to {"xmp"}
tell application "Finder"
set the_delete_list to {}
set delete_list to a reference to the_delete_list
-- populate list of items to delete
repeat with the_item in input
set the_item to (the_item as alias)
if name extension of the_item is in ext_list then
copy the_item to the end of delete_list
set parent_folder to (container of the_item) as alias as text
set item_name to text 1 thru ((length of (the_item's name as text)) - (length of (the_item's name extension as text))) of (the_item's name as text)
repeat with ext in other_ext_list
try
copy ((parent_folder & item_name & ext) as alias) to the end of delete_list
end try
end repeat
end if
end repeat
-- delete the items, show info dialog
move the_delete_list to the trash
display dialog "Moved " & (length of the_delete_list) & " files to the Trash." buttons {"OK"}
end tell
end run
可以很容易地編寫一個AppleScript(它可以但不需要,被嵌入的Automator工作流),但我真的不明白這一點:爲什麼不只是按文件名對Finder視圖進行排序,選擇所有你想擺脫的文件,然後點擊cmd + baskspace? – fanaugen 2012-03-12 08:42:15
好問題 - 我希望能夠滾動瀏覽通過EyeFi卡上傳的完整圖像的目錄,只需拖出那些我不想保存的圖像,而不必擔心找到要刪除的匹配XMP文件(以及不必滾動瀏覽XMP文件)。 – 2012-03-13 03:58:08