在 AppleScript 中逐行迭代文件?

发布于 2024-09-11 09:02:24 字数 147 浏览 3 评论 0原文

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

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

有什么提示吗?谢谢!

I am trying to figure out how to iterate through a file line by line in AppleScript. Similar to a bash script like so:

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

Any tips? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅气称霸 2024-09-18 09:02:24

我不能因为写这篇文章而获得荣誉,我从 对 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 论坛上的 HexMonkey

I can't take credit for writing this, I lifted the code from a response to a post in the MacRumors forums.

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

Original code credit to HexMonkey on the MacRumors forum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文