Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applescript Read File line by line

Tags:

applescript

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!

like image 956
Tom Keenan Avatar asked May 22 '15 23:05

Tom Keenan


1 Answers

# 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
like image 103
mklement0 Avatar answered Oct 13 '22 16:10

mklement0