tags:

views:

21

answers:

2

I have the following code to read contents from a file to open multiple Safari browsers.

set locations to paragraphs of (read (choose file with prompt "Pick text file containing urls"))
repeat with aLocation in locations
    tell application "Safari" to open location aLocation
end repeat

How can I read contents from pbcopy (copied result from Command-C action)? I tried as follows, but I couldn't get the lines, but the alphabets.

try
    set the locations to Unicode text of (the clipboard as record)
on error errMsg
    display dialog errMsg
end try
A: 

Probably the easiest thing to do is to make a bash script that will invoke pbpaste then use osascript -e to execute applescript within.

Jamie Wong
+2  A: 

If the clipboard contains text whose lines are URLs, you can retrieve those URLs by using the following script:

set locations to paragraphs of (the clipboard as Unicode text)
sakra