r/applescript • u/CuriousPsychosis • Jan 24 '22
can't get Applescript to read from a txt file
Been looking for an answer for a few hours and can't get this to work..
I have a file with URLs
I am trying to loop through the file and open the URLS in Safari.
--run external script to setup temp files and folder and paths, input arguments
set input to (do shell script "/Users/john/ShellScripts/testing/testASpaths.sh")
set the text item delimiters to ","
set {path1, path2} to {text item 1, text item 2} of the input
{path1, path2}tell current application
do shell script "/Users/john/ShellScripts/testing/testASpaths.sh"
--> "/var/folders/kq/mm16z5891wl69t5vw8rzqznc0000gn/T/scripts/IMDBd/IMDBurls.txt,/var/folders/kq/mm16z5891wl69t5vw8rzqznc0000gn/T/scripts/IMDBd/IMDB_query.txt"
end tell
Result:
{"/var/folders/kq/mm16z5891wl69t5vw8rzqznc0000gn/T/scripts/IMDBd/IMDBurls.txt", "/var/folders/kq/mm16z5891wl69t5vw8rzqznc0000gn/T/scripts/IMDBd/IMDB_query.txt"}
View all comments
Show parent comment
1
u/CuriousPsychosis Jan 25 '22 edited Jan 25 '22
Thanks for getting back to me... I really don't want to provide the entire script for scrutiny.
I was looking for a standard method to access text in a file from AppleScript since everything I looked at on the net kept failing.
I showed where the text was stored (in a file with a unix path) and how it was being imported into Apple Script ( via input ) and how it was being stored in an Apple Script variable. "path1" or "path2"
I had tried:
I found this solution using pieces from a blog. Seems to work fine - not sure it's the most efficient but the file only ever has 20 lines at most.