Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在AppleScript中逐行遍历文件?_Applescript - Fatal编程技术网

在AppleScript中逐行遍历文件?

在AppleScript中逐行遍历文件?,applescript,Applescript,我试图弄清楚如何在AppleScript中逐行遍历文件。类似于bash脚本,如下所示: for LINE in $(cat file) do echo ${LINE} done 有什么建议吗?谢谢 写这篇文章的功劳不在我,我从MacRumors论坛上的一个 tell application "Finder" set Names to paragraphs of (read (choose file with prompt "Pick text file containing trac

我试图弄清楚如何在AppleScript中逐行遍历文件。类似于bash脚本,如下所示:

for LINE in $(cat file)
do
   echo ${LINE}
done

有什么建议吗?谢谢

写这篇文章的功劳不在我,我从MacRumors论坛上的一个

tell application "Finder"
  set Names to paragraphs of (read (choose file with prompt "Pick text file containing track names"))
  repeat with nextLine in Names
    if length of nextLine is greater than 0 then
      --Do something with the next name, which is stored in "nextLine"
    end if
  end repeat
end tell

原始代码在MacRumors论坛上发布。

无需告诉查找者执行这些操作。您应该从Finder-tell块中删除所有代码。Applescript可以自己处理代码,而且查找程序经常忙于其他任务,因此它甚至可能会减慢代码的速度。很高兴知道。总有一天我真的应该学会自己写苹果P