Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript Scripting Error

Put quite simply I am trying to make an applescript in OS X that will let me cycle through a list of URLs to make a playlist of the songs I want to play. Each song should open a new page in Safari that goes straight to a youtube page. I don't know how to structure the last command line that would repeat the act of cycling through the whole list. Here is the script:

(* Apologize, Hall of Fame, Eye of the Tiger, Bon Jovi - Livin' on a Prayer, Somebody Told Me -the Killers, Ocena Avenue, The Reason, Since u been gone, Comin' home, Speed of Sound, the chronicles of life and death ,mr. brightguy,hanging by a moment,how you remind me,wherever you go,suddenly I see,behind blue eyes,I’m with you,someday -nickelback,The Fighter -Gym Class Heroes ft Ryan Tedder

*)

set myPlaylist to {"https://youtu.be/yGpGsG8bvWk", "https://youtu.be/jukv9Q1eR2g", "https://youtu.be/btPJPFnesV4", "https://youtu.be/lDK9QqIzhwk", "https://youtu.be/p4_1t5jjo4w", "https://youtu.be/9S5LA_c6WT8", "https://youtu.be/p4_1t5jjo4w", "https://youtu.be/R7UrFYvl5TE", "https://youtu.be/vCbQ_4PxM0E", "https://youtu.be/bnfRq69nKEA", "https://youtu.be/w08_Riw8vN4", "https://youtu.be/SrkeWsQZNyU", "https://youtu.be/a4_woZ-LUvM", "https://youtu.be/yyLsPdOEBww", "https://youtu.be/ThaW-YMFVus", "https://youtu.be/fEGI9NbH-mk", "https://youtu.be/1aFied2YYVg", "https://youtu.be/kmFWDUQMj-g", "https://youtu.be/8TzCLpgbJ_g"}

set Apologize to item 1 of myPlaylist

set HallofFame to item 2 of myPlaylist

set EyeoftheTiger to item 3 of myPlaylist

set LivingonaPrayer to item 4 of myPlaylist

set SomebodyToldMe to item 5 of myPlaylist

set OceanAvenue to item 6 of myPlaylist

set TheReason to item 7 of myPlaylist

set SinceuBeenGone to item 8 of myPlaylist

set ComingHome to item 9 of myPlaylist

set SpeedofSound to item 10 of myPlaylist

set TheChroniclesofLifeandDeath to item 11 of myPlaylist

set MrBrightguy to item 12 of myPlaylist

set HangingbyaMoment to item 13 of myPlaylist

set HowYouRemindMe to item 14 of myPlaylist

set WhereverYouGo to item 15 of myPlaylist

set SuddenlyISee to item 16 of myPlaylist

set BehindBlueEyes to item 17 of myPlaylist

set ImWithYou to item 18 of myPlaylist

set Someday to item 19 of myPlaylist

set TheFighter to item 20 of myPlaylist


The error message is

Syntax Error

Expected expression but found "repeat"

tell application "Safari" to makenewdocumentwith properties {URL:repeat myPlaylist}

Honestly I don't know why it won't work, do I need to structure the ending command line differently or what? Any help would be greatly appreciated, I have been scripting in Applescript proficiently for a few months now but this has me completely thrown for a loop (pun intended).

MacBook Air

Posted on Jun 28, 2015 9:58 AM

Reply
Question marked as Best reply
3 replies
Question marked as Best reply

Jul 1, 2015 12:32 PM in response to SGIII

Thanks, I will use that structure, I have been toying with the idea to use

repeat with aUrl in myPlaylist

tell application "Safari"

tell window 1


makenewdocumentwith properties {URL:whatevertheURLis}

end tell

end tell

end repeat

To make new tabs instead of a new document

The only problem is I have tried the approach and while my playlist is working fine I keep getting error number 10000 "AppleEvent Handler Failed" so I have just given up on the making a new tab instead of window. Thanks though, I am going to keep on working on it until I get it perfect. 🙂

BTWs if you ever adopt this idea make sure to put about a 255 second delay or else all the tabs open at once,

Jul 1, 2015 12:51 PM in response to chevydogincode

chevydogincode wrote:

To make new tabs instead of a new document


Here's an approach that makes new tabs (list of urls shortened to make testing easier):


SG



set myPlaylist to {"https://youtu.be/yGpGsG8bvWk", "https://youtu.be/jukv9Q1eR2g"}


tell application "Safari"


makenewdocument

tell window 1

repeat with aUrl in myPlaylist


makenewtabwith properties {URL:aUrl}

end repeat


deletetab 1 -- to remove Favorites tab that can appear by default

end tell

end tell

Applescript Scripting Error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.