I am trying to make applescript read a txt file and open each string (an url) in a new safari window. I do not know how to parse the files.
All i know how to do is
tell application "Safari"
activate
for i=25
open location "urlx"
next
end tell
where urlx would be a line in the file and be change to the next line/url every loop.
What i want to do is be able to change i to have a certain number of pages open, and not all 300+ urls, and to be able to start at a certain number as well, like start at line 35 and have it run 5 times after that so that it ends at 40.
Also, but not needed, i would like to be able to open the new window behind the last one created, much like Command-Shift-Click would. I would also rather have this parse from stickies, but since it is not applescriptable, thats a pipe dream.
set x to paragraphs of (read alias "path:to:file.txt")
--> open all urls
repeat with i in x
tell application "Safari" to open location i
end repeat
--> inverse order if you wish so (the first url in the file will be the frontmost window):
repeat with i from (count x) to 1 by -1
tell application "Safari" to open location (x's item i)
end repeat
--> pick only urls 2 thru 4
repeat with i from 2 to 4
tell application "Safari" to open location (x's item i)
end repeat
--> and a sample combo, open urls 2 thru 4, inverse order:
repeat with i from 4 to 2 by -1
tell application "Safari" to open location (x's item i)
end repeat
Actually, there is one more thing. Is there a way to parse the file to get the number of lines/paragraphs automaticaly and have it report in applescript?
//edit: Just realized that the first line does that for me. ha. I though i had to count and change x by hand, stupid me. Thanks alot, I owe you.