Applescript逐行读取文件

Applescript Read File line by line

我想制作一个读取文本文件的 applescript,并在移动到下一行并将其复制到剪贴板。谢谢!

# Determine the input file's path.
set srcFile to ((path to desktop) as text) & "myFile.txt"

# Read lines from file.
set lns to paragraphs of (read file srcFile as «class utf8»)

# Loop over lines read and copy each to the clipboard.
repeat with ln in lns
    set the clipboard to ln
    display alert (the clipboard)
end repeat