我想在具有多个嵌套文件夹层次结构的磁盘上的所有具有两个特定扩展名的文件上运行脚本。当我选择一个带有较少子文件夹的文件夹时,我的脚本运行良好,但我希望在具有上千个文件夹的整个档案中运行它。AppleScript永久占用get
所有文件,然后退出而不返回任何内容,并且在获取文件后不执行任何操作。没有超时消息,没有错误消息。并且Finder变得无响应(并且在脚本退出后仍然停留)。
set myFolder to choose folder with prompt "Choose a folder:"
tell application "Finder"
try
set eafFiles to (every file in entire contents of myFolder whose name ends with ".eaf") as alias list
on error
try
set eafFiles to ((every file in entire contents of myFolder whose name ends with ".eaf") as alias) as list
on error
set eafFiles to {}
end try
end try
try
set pfsxFiles to (every file in entire contents of myFolder whose name ends with ".pfsx") as alias list
on error
try
set pfsxFiles to ((every file in entire contents of myFolder whose name ends with ".pfsx") as alias) as list
on error
set pfsxFiles to {}
end try
end try
set myFiles to eafFiles & pfsxFiles
end tell
repeat with CurrentFile in myFiles
set CurrentFile to CurrentFile as string
do shell script "perl /path/to/perl/script.pl " & quoted form of CurrentFile
end repeat
1
您要如何处理找到的文件?一的bash脚本可能是去一个更有效的方式。
—
user3439894 '16
我通过以下方式将它们传递给perl脚本
—
扬
do shell script "perl " & quoted form of perlScript & " " & quoted form of CurrentFile
:我敢肯定有一种更好的方法,但是我的脚本编写技能几乎仅限于applescript。