我目前正在使用这个 Applescript,我发现它搜索文件名并在文本文档中返回文件路径。这适用于查找 1 或 2 个文件,但我想查找分布在数百个文件夹中的 500 个文件。我理想的脚本将使用来自 excel 电子表格或 csv 的数据,执行搜索,找到文件并将其复制到我桌面上的指定文件夹中。任何帮助表示赞赏。
这是我找到的脚本:
tell application "System Events"
activate
set thePattern to text returned of (display dialog "Search for" default answer "")
end tell
if thePattern = "" then return
try
set foundFiles to do shell script "mdfind -name " & quoted form of thePattern & " | /usr/bin/egrep -i " & quoted form of thePattern & "[^/]*/?$ | /usr/bin/grep -vi " & quoted form of thePattern & ".*" & quoted form of thePattern
on error
set foundFiles to "Nothing Returned"
end try
if foundFiles = "" then set foundFiles to "Nothing Returned"
tell application "TextEdit"
activate
delay 0.5
try
set theDoc to document 1
get text of theDoc
if result is not "" then
make new document
set theDoc to result
end if
on error
make new document
set theDoc to result
end try
set text of theDoc to foundFiles
end tell