4 Replies Latest reply on May 11, 2012 4:58 PM by ch0c0halic

    Making Alias to Client folder

    fredrogers

      I would like to make a script that would create a directory of aliases to clients project folders.

       

      My staff members need to access clients working folders to save projects in.

      All of the clients folders are in a share on our fileserver.

       

       

      What I would like is some kind of script that will make a directory on a share with the staff members name, then fill the directory with aliases to that staff member's assigned clients' project folders.

       

      I do have a relationship from the clients to the staff members and I have a calculation to the clients folders.

       

      I have used scriptworks 360 Scriptmaster to create folders in the past, but I am not sure if I should use that or some other script to create the staff folders.

       

      Then on making the aliases is where I need the most help.

       

      Thank you for your time!

       

      -=fred=-

       

      PS if i omitted some important information let me know

        • 1. Re: Making Alias to Client folder
          fredrogers

          Well I solve my issue.

           

          I thought I would post my script incase anyone was interested.

           

          Set Variable [ $staff; Value:Staff::Full Name ]

          Set Variable [ $clientfolder; Value:"/Volumes/ClientDrive/"&Clients::Last First ]

          Set Variable [ $client; Value:Clients::Last First ]

          Set Variable [ $target; Value:"/Volumes/Test Alias/" ]

          Set Variable [ $makefolder; Value:"set make_folder to POSIX file "&Quote($target)&" as alias"&¶&

          "try"&¶&

          "tell application \"Finder\"" & ¶ &

          "Make new folder at make_folder"& ¶ &

          "set name of result to"&Quote($staff) & ¶ &

          "end tell"&¶ &

          "on error errmsg number errNum"&¶ &

          "delete result"&¶&

          "end try" ]

          Perform AppleScript [ Calculated AppleScript: $makefolder ]

          Set Variable [ $makealias; Value:"set location_folder to POSIX file "&Quote($target&$Staff&"/")&" as alias"&¶&

          "set target_folder to POSix file "&Quote($clientfolder)&"as alias"&¶&

          "try"&¶&

          "tell application \"Finder\"" & ¶ &

          "make new alias file at location_folder to target_folder"& ¶ &

          "set name of result to"&Quote($client) & ¶ &

          "end tell"&¶ &

          "on error errmsg number errNum"&¶ &

          "try"&¶ &

          "delete result"&¶&

          "end try"&¶ &

          "end try" ]

          Perform AppleScript [ Calculated AppleScript: $makealias ]

           

          -=fred=-

          • 2. Re: Making Alias to Client folder
            ch0c0halic

            Fred may be watching a falling Apple,

             

            Congratulations.

             

            I suggest you add a field in FMP, called 'results'?, and set it at the end of the AppleScript with a pass or (multiple) fail value. Add a "Set AS_result to errnum" to the "on error" AS sequences so you know if the folder/file didn't get created (and can abort the file processing if required). Then pass back the 'AS_result' variable to the FMP field 'results' at the end of the AS. In the FM Script maybe add sending a notification email to you if you get an error number?

            • 3. Re: Making Alias to Client folder
              fredrogers

              I like it!

               

              How do would you pass the results? With an error capture?

               

              Thanks!

               

              -=fred=-

              • 4. Re: Making Alias to Client folder
                ch0c0halic

                You'd set the FileMaker field 'results' to the error number previously stored in a variable.

                 

                 

                In this AppleScript I set the field "gdefault_folder_path" to the name of the folder just created.

                 

                "tell application " & "\"" & "Finder" & "\"" & "¶" &

                "set addpath to false¶" &

                "set fshared to alias ((startup disk as text) & " & "\"" & order_processing::gdestination_path & "\"" & ")" & "¶" &

                "set wsfolder to (fshared as text) & " & "\"" & order_processing::gdestination_filename & "\"" & "¶" &

                "if exists folder wsfolder then¶set wsfolder to folder wsfolder as text¶"&

                "set addpath to true¶" &

                "end if¶" &

                "end tell¶" &

                "if addpath then¶"&

                "set field " & "\"" & "gdefault_folder_path" & "\"" & " to wsfolder¶" &

                "end if"

                 

                 

                 

                In your case:

                "set field " & "\"" & "results" & "\"" & " to my_errnum¶" &

                 

                Where the variable 'my_errnum' has the previously recorded error number of the 'Try' statements.