好的,明白了。您可以使用下面给出的的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