4 Replies Latest reply on Apr 21, 2015 6:24 AM by PeterAndersson

    Need some help with an Apple script

    PeterAndersson

      Title

      Need some help with an Apple script

      Post

      I'm trying desperatly to get my applescript to work (It works great in the apple script editor, but filemaker refuses to accept it.

      Could anyone please point me in the right direction?

      Thanks!

       

      This is my script that should create a folder and tag it:

      "tell application \"Finder\"¶
      make new folder at alias \":Volumes:Jobb:\" with properties {name:\"" & arbetsorder::Mappnamn & "\"}¶
      end tell"

      if (arbetsorder::Ansvarig = "Peter Andersson") then¶

          set username to "Peter"¶
      end if¶

      do shell script "/Volumes/Jobb/_Peter/tag/tag -r \* " & \":Volumes:Jobb: & arbetsorder::Mappnamn\"¶
      do shell script "/Volumes/Jobb/_Peter/tag/tag -a " & username & " " & \":Volumes:Jobb: & arbetsorder::Mappnamn\"¶

       

        • 1. Re: Need some help with an Apple script
          FentonJones

          Since it worked in AppleScript, and since it has only a few lines which tell FileMaker to do much, I would guess that the problem is in the lines where you specify the person's name, "Peter Andersson", then "Peter", but you did not protect the quote marks. Try it with \"Peter Andersson\" and \"Peter\"

          One method I use is to create a calculation field (unstored), to show me what the result of the calculation looks like. You would have seen that the person's name was not in the result with quotes around it (which would look odd).

          It's good to name such posts "AppleScript Script" instead of just "Script", as I did not notice that this was an AppleScript question, until I looked at it.

          • 2. Re: Need some help with an Apple script
            PeterAndersson

            Thanks for helping out!
            I'm really a novice when it comes to filemaker and applescript, i'm more used to php, bash and javascript. So this is all new to me.

            Sadly escaping the quotes didn't do the trick. I get the message "The specified table cannot be found". Which is strange, because i know the "tell application \"Finder\"" part works. But if I duplicate that part I get the same error message.

            I just can't understand why. If you have any other ideas I'd be more than happy to try them!
             

            The updated script:

            "tell application \"Finder\"¶
            make new folder at alias \":Volumes:Jobb:\" with properties {name:\"" & arbetsorder::Mappnamn & "\"}¶
            end tell"

            If [arbetsorder::Ansvarig = \"Peter Andersson\"] then¶
                set username to \"Peter\"¶
            end If¶

            do shell script \"/Volumes/Jobb/_Peter/tag/tag -r \\* \" & \":Volumes:Jobb: & arbetsorder::Mappnamn\"¶
            do shell script \"/Volumes/Jobb/_Peter/tag/tag -a \" & username & \" \" & \":Volumes:Jobb: & arbetsorder::Mappnamn\"¶

            • 3. Re: Need some help with an Apple script
              zinny

              I am also a complete novice (Fenton fixed my apple script) but your first end tell doesn't have a hard return on it so that might be a problem.

              • 4. Re: Need some help with an Apple script
                PeterAndersson

                Thanks for the reply!

                That help. I finally gave this up and chose the easiest option. I made a bash script and did everything there, it's so much easier than douple quoting and escaping every string.

                This is what i ended up with (in case someone wants to know).

                "do shell script \"/Volumes/Jobb/_Peter/tag/changetag.command " & "\\\"" & arbetsorder::Ansvarig & "\\\"" & " \\\"" & arbetsorder::Mappnamn & "\\\"" & "\""

                Thanks for the help everyone!