Applescript逐行读取文件

时间:2015-05-22 23:04:36

标签: applescript

我想制作一个读取文本文件的AppleScript文件,并且每行都将文本复制到剪贴板(从这里开始对它进行排序),然后移到下一行并将其复制到剪贴板。谢谢!

1 个答案:

答案 0 :(得分:4)

# 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