3 Replies Latest reply on Oct 6, 2015 4:12 PM by erolst

    How to add spaces between folders a script creates

    dyb

      Dear Filemaker Community,

       

      I wanted to create a script that will create a number of folders which names are based on user input text from specified fields.

      I have this script (script step: Perform AppleScript):


      Let ([Qmk = "\""; var1 = Table1::Field1; var2 = Table1::Field2; var3 = Tabel1::Field3];

      "do shell script " & Qmk & "mkdir -p /MainDirectory/" & var1 & var2 & "/" & var3 & "/" & var1 & "{sub1,sub2,sub3}" & Qmk)

       

      The script is able to create file structure like this:

      var1var2

           var3

                var1sub1

                var1sub2

                var1sub3

      I am would be very pleased if i could add spaces to the folder names.

      var1 var2

           var3

                var1 sub1

                var1 sub2

                var1 sub3

       

      So far i get only errors with "permission denied".


      I can easily create folders like this using terminal but apparently i am completely new to filemaker...


      Terminal works like this:

      mkdir -p '/MainDirectory/var1 var2'

      mkdir -p /MainDirectory/'var1 var2'

      mkdir -p /MainDirectory/"var1 var2"

      or even like this

      mkdir -p /MainDirectory/var1\ var2

       

       

      How can i manage this in filemaker?

        • 1. Re: How to add spaces between folders a script creates
          erolst

          Wrap the argument into single quotes?

           

          "do shell script " & Qmk & "mkdir -p "

          & "'" &

          "/MainDirectory/" & var1 & var2 & "/" & var3 & "/" & var1 & "{sub1,sub2,sub3}"

          & "'" &

          Qmk)

          1 of 1 people found this helpful
          • 2. Re: How to add spaces between folders a script creates
            dyb

            I tried to do this but failed at some point. Your code was clear... I guess i'm tired.

             

            Also i put the closing single quote before the brace expansion and put the obviously needed spaces:

            If somebody is interested in this script here it is:

            Let ([Qmk = "\""; var1 = Table1::Field1; var2 = Table1::Field2; var3 = Tabel1::Field3];

            "do shell script " & Qmk & "mkdir -p "

            & "'" & "/MainDirectory/" & var1 & " " & var2 & "/" & var3 & "/" & var1 & " " & "'" & "{sub1,sub2,sub3}" & Qmk)

             

             

            What i would like to do next with this script is to put spaces in names from the brace expansion list so that


            sub1 = word & " " & word

             

            Thank you very much for the quick response!

            • 3. Re: How to add spaces between folders a script creates
              erolst

              I simply looked at the form about which you said it works in the Terminal, then try to find the spots where the single quotes seem to go; I didn't actually test it.

               

              It may be a good idea to create the string you want to pass to AppleScript in a variable first and inspect/compare the result in a Custom Dialog (or, much better, test the calculation in the Data Viewer, if you have FM Advanced, then try the result in the AS Editor).