1 Reply Latest reply on Apr 10, 2015 5:09 PM by FentonJones

    Apple script calculation error



      Apple script calculation error


      I am doing my first perform apple script step (which also happens to be my first apple script).

      I am trying to grab the location of a quicktime file and then open the folder it is in using an apple script.

      I can hard code the information into the "Native Script Application" option as below

      openfolder "open this" offolder "Desktop" offolder "Reuben Macbook" offolder "Users" ofstartup diskofapplication "Finder"

      and it works find but I need to be able to find the folders of different quicktimes and when I replicate the statement exactly in a calculation it comes up with 

      A """ can't go after this property

      and Unknown error - 2470

      I have tried putting the calculation directly into the apple script script step, sending it as a variable and calculating it as a global field and then linking the calculation to that but all cases the errors are the same

      So here is my calculation

      "open folder \""& GetValue (test::filepathasreturn;ValueCount ( test::filepathasreturn ) -1 ) & "\" of folder \""& GetValue (test::filepathasreturn;ValueCount ( test::filepathasreturn ) - 2) & "\" of folder \"Reuben Macbook\" of folder \"Users\" of \"startup disk\" of application \"Finder\""

      My solution is to substitute the / in the path name with a hard return (currently as the field FILEPATHASRETURN so I can see it) and then get the last value -1 and the last value -2 as my variable folders (the last value is the quicktime name). All the others are hardcoded because in the final solution they will not be changing.

      so the filepath in my test looks like this

      mac:/Macintosh HD/Users/Reuben Macbook/Desktop/open this/ADVENTURE.mp4


      My final calculation looks like this

      open folder "open this" of folder "Desktop" of folder "Reuben Macbook" of folder "Users" of "startup disk" of application "Finder"

      but I get the error codes - what am I doing wrong?

      Thanks so much for any responses

        • 1. Re: Apple script calculation error

          The problem is that "startup disk" should not be used as if it was just text; it is a special thing to the "Finder" application. So you don't want to put it in quotes. If you need to produce it as one line for AppleScript, this should work:

          tell application "Finder" to open folder "open this" of folder "Desktop" of folder "Reuben Macbook" of folder "Users" of startup disk

          If this the folder is in the current Desktop, and you just want to open a folder on it, this should be a shorter method:

          tellapplication "Finder" toopen ((path todesktop) & "open this:") astext