当前位置: 动力学知识库 > 问答 > 编程问答 >

Applescript Read File line by line

问题描述:

I'd like to make an applescript that reads a text file and for each line copies the text to the clipboard (what it does with it from here I have sorted) before moving onto the next line and copying that to the clipboard. Thanks!

网友答案:
# 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
分享给朋友:
您可能感兴趣的文章:
随机阅读: