1 2 Previous Next 27 Replies Latest reply on Sep 7, 2010 10:45 AM by philmodjunk

    Create and Link folders

    CraigFiore

      Title

      Create and Link folders

      Post

      Hello everyone,

      This might be a tuff one. Can anyone let me know how I can have a button in FMP create a folder on our server then create a link to it that is connected to the specific record.

      Thanks for your help,

      Craig

      FMP 10

        • 1. Re: Create and Link folders
          philmodjunk

          Not with just FileMaker. There are some file/folder manipulation plug-ins out there. One: MooPlug is free but windows only.

          • 2. Re: Create and Link folders
            CraigFiore

            Bummer, Im on a mac. 

            Is there any other alternative. I want to have a way to attach or link other documents. I just dont know how many will be on each record.

            • 3. Re: Create and Link folders
              philmodjunk

              Open URL, Container Fields and web viewers can all be used to link a record to a document. No real need for a folder on the database side.

              Instead of linking an unknown number of documents to the same record, create a table of related records and link one document to each related record. This can be as simple as inserting a file into a container. If you want you can set this up so you insert the file and then a filemaker script exports the file to a shared folder on the server, then re-inserts it by reference into the appropriate record's container field.

              There's also a third party product called supercontainer that some have recommended.

              • 4. Re: Create and Link folders
                CraigFiore

                Thanks for you help Phil.

                I like to look at the second option a bit more (create a table...). Do you know were I could read on how to do that?

                • 5. Re: Create and Link folders
                  FentonJones

                  On a Mac there is a built-in Unix tool to create folders (and folder hierarchies) named 'mkdir' ("make directory" to humans). It has an option '-p' to create whatever folders are needed for the hierarchy, without overwriting any existing folders. It works on mounted volumes also. It can be run via AppleScript, as a FileMaker Perform AppleScript script step. (Similar exists in Windows command line, 'md')

                  It is a fairly safe command, as far as Unix command line goes. But if you get the path wrong, you may get folders created in unexpected places (like at the top level of your hard drive). No big deal, you can delete them. It will never overwrite an existing folder.

                  Since you'd be supplying the path and name of the folder mostly from a FileMaker field, and the name may have spaces in it (which must be escaped in Unix paths), and since quotes have special meaning to both AppleScript and FileMaker the main trick is getting the quotes you need and not the ones you don't. 

                  Because you're only supplying one piece of data from FileMaker, you can create a calculation for the entire command, and run it in a Perform AppleScript step via the "Calculated AppleScript" option. This way the field supplying does not even need to be on the layout; though likely it would be.

                  A good way to get the command right is to create a calculation field, so you can see the result. The result should be "Text," and the Storage [x] Do not store. If the name of the FileMaker field is "FolderName," pseudo code:

                  "do shell script \"mkdir -p \" & quoted form of \"/Volumes/mounted name/" & FolderName & "\""

                  Yeah, crazy quotes. The result looks something like this, a mixture of AppleScript running a Unix command:

                  do shell script "mkdir -p " & quoted form of "/Volumes/manavesh/Fenton Jones"

                  The phase "quoted form of" is an AppleScript command to make text "Unix-safe" (though it does nothing to line endings, but we don't care about that right now).

                  The FolderName field could be a hierarchal path, such as "Companies/some company name". 'mkdir -p ' (always a space after the command) will create both folders, if needed, or only the 2nd within the 1st, if the 1st exists. There are even wilder combos, but that should be enough.

                  As far as a "link to the folder", it would be another calculation. If you mean a link to open the folder, modify the calculation:

                  "do shell script \"open \" & quoted form of \"/Volumes/manavesh/" & FolderName & "\""

                  which produces:

                  do shell script "open " & quoted form of "/Volumes/manavesh/Fenton Jones"

                  [P.S. I would use a FileMaker ID field instead of the name generally; but either would work. Just don't go change the name of the folder later.]

                  • 6. Re: Create and Link folders
                    CraigFiore

                    Thanks for the help Fenton, 

                    I understand some of what you said :) It may be too advanced for me to do. But if i understand, I would wright a script in FMP and to work with a script that i wright for the MAC.

                    If I am correct, would I have to go to each Computer on the Network and manualy wright the script?

                    • 7. Re: Create and Link folders
                      FentonJones

                      It is not really that advanced. The actual command is pretty short. But it is difficult to make the quotes come out right in a FileMaker calculation. Which is why you need to do it in an unstored calculation field until you get it right.

                      In a networked situation, this is just a FileMaker field/script much like any other, in the hosted file. It is NOT an external AppleScript file. It evaluates at runtime on each client machine. But since they all see the "file server" via the same path, it works the same on all the (Mac) client machines. 

                      Folder creation or open can be a single Perform AppleScript step (in the Miscellaneous section, near the bottom). FileMaker runs AppleScript very well, quite fast.

                      • 8. Re: Create and Link folders
                        CraigFiore

                        Thanks,

                        It still maybe over my head. I will look more closely at it when I do some work over the weekend. One question, do i need to be running FMP Server? Because I am not. We have a small network with only four people. We are using just FMP (not advanced).

                        Craig

                        • 9. Re: Create and Link folders
                          FentonJones

                          Here is an example file (for a while). It has a few options. It has both the "plain jane" AppleScript, as well as the AppleScript running Unix command (recommended). It has a couple methods/buttons that create the folder on the Desktop, to show how it is done. 

                          It also has an extension of the above, where it Saves As PDF the current records, creates the folder on the DT (if needed) and puts the PDF in it.

                          It also has a "Volumes" one to create on a mounted volume, and one to open that folder. But you must put your volume's name into the calculation, or it is not going to work. 

                          http://fentonjones.com/New/Folder_from_field.fp7.zip

                          • 10. Re: Create and Link folders
                            CraigFiore

                            Your sample is great for testing and it seems to be working except that i can not seem to create the folder on the sever.

                            My Server is "Celoseal Server" Then a drive called "Documents" than a folder called "FMP Folders"

                            Get Info:

                            Where:/Volumes/Documents

                            Server:afp://192.168.15.5/Documents/FMP Folders

                            • 11. Re: Create and Link folders
                              FentonJones

                              So you'd put "/Volumes/Documents/" in the calculation where I put just "/Volumes/" 

                              Then "FMP Folders" for the Folder Name field.

                              And the Documents drive would need to be mounted. That AppleScript will not mount it. Though there are AppleScript commands to do that. But easiest to just mount it manually.

                              • 12. Re: Create and Link folders
                                CraigFiore

                                I got the sample file you wrote to make a folder on the server and it works great. But when I copied the 

                                _cFolder_AS Volumes_Unix  to my Database with the button and script. I could not get it to work. What am i missing?

                                • 13. Re: Create and Link folders
                                  FentonJones

                                  Did you see my earlier post today? You have to put your path into the calculation. You can't just copy/paste it from my file and expect it to work. I do not have your server nor your paths, so I can only write a path which I do have. It is not hard to adjust however.

                                  • 14. Re: Create and Link folders
                                    CraigFiore

                                    I did not copy and paste. I ended up having the applescript typed incorrectly. I also created a script that connects both the create folder and open folder to make one button. This will make if easier for the people at the office. 

                                    The only issue i am having right now is, if the computer is not connected to the server, FMP will create a folder on the current computer. Is there a way to have it only go to the server?

                                    Thanks for your help.

                                    One last challenge, is it possible to make a field that will show the names of all the files in the folder that is created?

                                    1 2 Previous Next