Take text from a file and enter it into Safari

I’m trying to write a script to take each line of a text document, put it into Safari’s address field, and do the equivalent of pressing enter, opening each line from the document in a new tab.

I have this:
tell application “BBEdit”
open file “Users:suzanna:file.txt”
cut first line of front document

but I am stuck with how to make it repeat the next line, as it doesn’t cut the whole line, just the text on it, leaving a blank line. I can’t work out how to paste things into Safari.

Hi suzanna,

I would not recommend using copy/paste for this and the use of BBedit seems not necessary if every line in your text doc is one URL. Sth. like this should work:


set theText to (do shell script "cat /Users/suzanna/file.txt")
set AppleScript's text item delimiters to return
tell application "Safari"
repeat with theURL in (every text item of theText)
	make new document
	open location theURL
end repeat

D. :slight_smile: