好的,我知道了。您可以在 Automator 工作流程中使用下面给出的 AppleScript,如下所示:
对于 Finder 中的每个选定文件,如果其扩展名为 . 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