2 Replies Latest reply on Mar 26, 2010 1:46 PM by buck_5648798798

    Reveal container contents  in Finder



      Reveal container contents  in Finder




      I wanted to reveal container contents in the Finder. I found this and it works:




      The FileMaker syntax full path to the file is the last line of what  
      you get with GetAsText (container field). The following returns the  
      AppleScript Mac path from either a file or image inserted into a  
      container field (by a Mac).
      Let ( [
      info = GetAsText ( Contain );
      vc = ValueCount ( info );
      FM_path = GetValue( info; vc )
      Substitute ( FM_path; ["imagemac:/"; ""]; ["filemac:/"; ""]; ["/";  
      ":"] )
      To reveal the file, use the following in a Perform AppleScript step,  
      with the by calculation option:
      Let ( [
      info = GetAsText ( Contain );
      vc = ValueCount ( info );
      FM_path = GetValue( info; vc );
      Mac_path = Substitute ( FM_path; ["imagemac:/"; ""]; ["filemac:/";  
      ""]; ["/"; ":"] )
      "tell application \"Finder\"¶" &
      "activate¶" &
      "reveal \"" & Mac_Path & "\"¶" &
      "end tell"


      The files are to be stored on a server. I want to add a custom message If the file isn't there or the server isn't mounted. Filemaker gives an error but it is a little confusing. I would also like to display different message if the file is not a reference.


      I'm adding this feature to an existing database that has images that are not stored as reference files. They are to be replaced with references as time goes by.  To help this process I'd like to be able to indicate whether the file is a reference or stored in the database. I have a field that displays the file path (a calculation "=container"). If the image is a reference my file path field has "imagemac/volume/imagename" in it. If not a reference it has just the file name. I cant figure out how to use this to trigger a value such as "on Server" or "Not on Server".




      FM Pro Advanced 10

      Mac 10.6.2

      Total Noob




        • 1. Re: Reveal container contents  in Finder

          First, this may be beyond your comfort zone, but since you asked...


          1. The following AppleScript (run as is, ie., native, via a Perform AppleScript step) with see if the server is mounted, using list disks, and attempt to mount it if it is not. This takes about 2.5 min (to fail). When I've done this I've included the data required in FileMaker fields, in a single-record "constants" table (which is used for many things, incl. some graphics for buttons, etc.). I had to do this, as my client's server is not my server. I've also added a comment, to show what the command to mount contains.


          --tellapplication "FileMaker Pro Advanced"

            setserver_mounttofield "z_cServer_Mount" oftable "cl_INT_Globals~X"

            -- "afp://" & Server_User & ":" & Server_PW & "@" & Server_IP & "/" & Server_Name

            setserver_nametofield "Server_Name" oftable "cl_INT_Globals~X"



          tellapplication "Finder"

           -- timeout doesn't help; still 2.5 min

            if (list disks) does notcontainserver_namethenmount volumeserver_mount



          It will quickly exit with no error if the server is mounted. The above must be in a FileMaker script, with Set Error Capture ["On"], then trap for any error. It exist with an error if it cannot mount the server, and you can then use a regular FileMaker dialog to tell them.



          2. To tell whether an image is "embedded" or referenced the simplest test is the FileMaker Length (container field) function. It returns bytes for embedded, 0 for referenced. It does not however tell whether the referenced image is there or not. There is no native function to do that. An AppleScript must be run. The Troi File plug-in can tell you via a calculation; but that costs $$.


          This is a simple Unix command line, run via AppleScript, to see if the file is there. In this case I hard-coded the start of the path (yeah, not consistent). I ran it in a Loop, to mark records where the file was missing. The flag field must be on the current layout; as is true for most AppleScript commands, unless you specify the table (occurrence) or layout.


          --tellapplication "FileMaker Pro Advanced"

            setunix_partial_pathtocell "FilePath" ofcurrent record

            setunix_pathtoquoted formof ("/Volumes/scan" & unix_partial_path)


            setunix_fileto (do shell script "test -f " & unix_path)


            setcell "Missing_flag" ofcurrent recordto 1





          The "tell FileMaker" lines are commented out above. FileMaker does not need or want them, not at the top level anyway; it is implied; FileMaker knows it is running the top level.

          • 2. Re: Reveal container contents  in Finder

            Wow! The man himself..


            I will try as soon as possible. You are right, beyond my comfort zone but I'm willing to put the hours in to learn.


            Thanks a lot and also thanks for the original Feb 2008 post on how to reveal files in finder. Brilliant.