尝试:
set myValues to {"3101", "3102", "3103", "3456", "6789"}
tell application "Finder" to set fileList to files of target of front window
set matchedFiles to {}
repeat with aFile in my fileList
repeat with aValue in myValues
tell application "System Events" to if aFile's name contains (contents of aValue) then set end of matchedFiles to (aFile as text)
end repeat
end repeat
tell application "Finder" to select matchedFiles
编辑 - 添加了 Finder 窗口和 regulus6633 的建议:
set myValues to {"3101", "3102", "3103", "3456", "6789"}
tell application "Finder" to set fileList to files of target of front Finder window as alias list
set matchedFiles to {}
repeat with aFile in my fileList
repeat with aValue in myValues
tell application "System Events" to if aFile's name contains (contents of aValue) then set end of matchedFiles to (aFile as text)
end repeat
end repeat
tell application "Finder" to select matchedFiles
编辑 2
set myValues to {"3125", "3123"}
tell application "Finder" to set fileList to files of target of front Finder window as alias list
set matchedFiles to {}
repeat with aFile in my fileList
repeat with aValue in myValues
tell application "System Events" to if aFile's name contains (contents of aValue) then set end of matchedFiles to (aFile as text)
end repeat
end repeat
if matchedFiles ≠ {} then
tell application "Finder"
select matchedFiles -- you don't need to select files to duplicate them
duplicate matchedFiles to (choose folder)
end tell
end if