Skip to main content
added 2 characters in body
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

If you're copying and pasting a list, as in what's shown in your question, as in lines of text that have athe (hidden) newline character at the end of each line, you can use the following:

 display dialog "Please Enter IDs" with icon caution default answer ""
set id_list to text returned of result

if id_list is not "" then
    set i to 1
    repeat (count paragraphs in id_list) times
        tell application "Google Chrome"
            make new tab at end of tabs of window 1 with properties {URL:(paragraph i of id_list)}
        end tell
        set i to i + 1
    end repeat
end if

Here's the Event Log fromin AppleScript Editor fromafter running the AppleScript code above:

tell application "AppleScript Editor"
    display dialog "Please Enter IDs" with icon caution default answer ""
        --> {text returned:"25082945 
25463469 
03146331 
36584524 
23461461", button returned:"OK"}
end tell
tell application "Google Chrome"
    make new tab at end of every tab of window 1 with properties {URL:"25082945 ""25082945"}
        --> tab id 428 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"25463469 ""25463469"}
        --> tab id 4511 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"03146331 ""03146331"}
        --> tab id 4814 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"36584524 ""36584524"}
        --> tab id 5117 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"23461461"}
        --> tab id 5420 of window id 1
end tell

If you're copying and pasting a list, as in what's shown in your question, as in lines of text that have a newline character at the end of each line, you can use the following:

 display dialog "Please Enter IDs" with icon caution default answer ""
set id_list to text returned of result

if id_list is not "" then
    set i to 1
    repeat (count paragraphs in id_list) times
        tell application "Google Chrome"
            make new tab at end of tabs of window 1 with properties {URL:(paragraph i of id_list)}
        end tell
        set i to i + 1
    end repeat
end if

Here's the Event Log from AppleScript Editor from running the AppleScript code above:

tell application "AppleScript Editor"
    display dialog "Please Enter IDs" with icon caution default answer ""
        --> {text returned:"25082945 
25463469 
03146331 
36584524 
23461461", button returned:"OK"}
end tell
tell application "Google Chrome"
    make new tab at end of every tab of window 1 with properties {URL:"25082945 "}
        --> tab id 42 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"25463469 "}
        --> tab id 45 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"03146331 "}
        --> tab id 48 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"36584524 "}
        --> tab id 51 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"23461461"}
        --> tab id 54 of window id 1
end tell

If you're copying and pasting a list, as in what's shown in your question, as in lines of text that have the (hidden) newline character at the end of each line, you can use the following:

display dialog "Please Enter IDs" with icon caution default answer ""
set id_list to text returned of result

if id_list is not "" then
    set i to 1
    repeat (count paragraphs in id_list) times
        tell application "Google Chrome"
            make new tab at end of tabs of window 1 with properties {URL:(paragraph i of id_list)}
        end tell
        set i to i + 1
    end repeat
end if

Here's the Event Log in AppleScript Editor after running the AppleScript code above:

tell application "AppleScript Editor"
    display dialog "Please Enter IDs" with icon caution default answer ""
        --> {text returned:"25082945
25463469
03146331
36584524
23461461", button returned:"OK"}
end tell
tell application "Google Chrome"
    make new tab at end of every tab of window 1 with properties {URL:"25082945"}
        --> tab id 8 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"25463469"}
        --> tab id 11 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"03146331"}
        --> tab id 14 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"36584524"}
        --> tab id 17 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"23461461"}
        --> tab id 20 of window id 1
end tell
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

If you're copying and pasting a list, as in what's shown in your question, as in lines of text that have a newline character at the end of each line, you can use the following:

 display dialog "Please Enter IDs" with icon caution default answer ""
set id_list to text returned of result

if id_list is not "" then
    set i to 1
    repeat (count paragraphs in id_list) times
        tell application "Google Chrome"
            make new tab at end of tabs of window 1 with properties {URL:(paragraph i of id_list)}
        end tell
        set i to i + 1
    end repeat
end if

Here's the Event Log from AppleScript Editor from running the AppleScript code above:

tell application "AppleScript Editor"
    display dialog "Please Enter IDs" with icon caution default answer ""
        --> {text returned:"25082945 
25463469 
03146331 
36584524 
23461461", button returned:"OK"}
end tell
tell application "Google Chrome"
    make new tab at end of every tab of window 1 with properties {URL:"25082945 "}
        --> tab id 42 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"25463469 "}
        --> tab id 45 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"03146331 "}
        --> tab id 48 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"36584524 "}
        --> tab id 51 of window id 1
    make new tab at end of every tab of window 1 with properties {URL:"23461461"}
        --> tab id 54 of window id 1
end tell