5 Replies Latest reply on Sep 27, 2010 3:03 AM by AndrewClyne

    Reference a folder, not file



      Reference a folder, not file



      I'm wandering if its possible to store a reference to a folder, not just a specific file. And I don't mean a folder of files, but just the folder itself.

      Using FMP11 & mac os



        • 1. Re: Reference a folder, not file

          If you can use AppleScript it is certainly possible to interact with a folder and its files from FileMaker. But FileMaker itself cannot store a reference to a folder directly (like in a container field). 

          It is possible to "list folder", to see what files are in it; then do something with the files. It is possible to create folders, and move files into/out of them.

          • 2. Re: Reference a folder, not file

            Hmm, ok. Thanks for that.

            What about just storing the path to the folder, then a script to launch the folder in finder. Or getting the parent folder from a file in a container field, then launching that folder

            • 3. Re: Reference a folder, not file

              Whoop Whoop. I got it!

              I learnt a lot about scripting in filemaker too.

              Cheers for pointing me in the correct direction!

              • 4. Re: Reference a folder, not file

                Could you share your solution, with specifics?

                Whoop Whoop is not very informative.

                • 5. Re: Reference a folder, not file

                  Haha, yeh. No bother.

                  I have a container field that references a file in the directory to open.

                  I then created a script:

                  Open Url[No dialog; "file:///Volumes" & Let ([CFilePath = GetValue(Get ( ScriptParameter ); 2);CLength = Length(CFilePath);CLastSlash = Position(CFilePath; "/"; CLength ; -1);CFirstSlash = Position(CFilePath; "/"; 0; 1);CBadPath = Left(CFilePath; CLastSlash)];Right(CBadPath; Length(CBadPath) - CFirstSlash + 1)) ]

                  When I was trying to work out how to do this, there was a lot of things saying pretty much that, but not what to do with them. For those that want to know (well, those who are learning):

                  Goto File->Manage->Scripts (well, on OSX)

                  Create a new script. Look in the left hand command browser for Open URL, and move to the list on the right. Then select the command you just added, and click the 'Specify...' button.

                  Then, on the dialog that pops up, click specify again.

                  Then type in your script. The following is an example for my machine. Customise to suit (#are comments. not sure if thats right. I added them for this post)

                  "file:///Volumes" & #this is the root directory for Mac osx local machine

                  #the following is a bit messy
                  Let (
                  [CFilePath = GetValue(Get ( ScriptParameter ); 2); #Get the filepath from a script param. Or this could be a table field (container)
                  CLength = Length(CFilePath); #Get the length of the filepath
                  CLastSlash = Position(CFilePath; "/"; CLength ; -1); #Get the position of the last slash, so we dont include the actual file
                  CFirstSlash = Position(CFilePath; "/"; 0; 1)] #Get the position of the first slash, to cut out the guff at the start

                  #This could probably be done with a Middle command
                  Right(Left(CFilePath; CLastSlash); Length(CBadPath) - CFirstSlash + 1)


                  And thats it really.

                  If anyone has optimisation hints, fire in. If anyone has a more robust solution for cross-platform, then do say.