1 Reply Latest reply on Oct 15, 2009 9:20 PM by FentonJones

    Telling the finder to move a PDF to a new folder prior to creating a link to FileMaker

    RPrevereau

      Title

      Telling the finder to move a PDF to a new folder prior to creating a link to FileMaker

      Post

      Hi,

       

      I've created a simple database to keep track of my reading notes in which I have a script that links each record to the PDF of the given article (using the "insert image"), so that I can open it from within the database. Now, considering the number of PDF's I have to manage, I would like to move those that are linked to my database from a folder named "PDF to link" to a folder named "PDF linked" as I create the link to my database records. The AppleScript for this latter option goes as follows:

       

      tell application "Finder"
          set _file to choose file with prompt "Select the PDF to move" without multiple selections allowed
          move file _file to folder "PDF linked" of folder "A" of disk "B"

          set _PDFpath to _file

      end tell

      tell application "FileMaker Pro"

          activate

      end tell

       

      That Applescript works pretty well, since the selected files are moved each time to the desired folder. The troubles begin when I try to create a link in FileMaker to the PDF that I just selected and moved. For I don't want to need to select that same PDF again. Instead, I want FileMaker to create the link based on the new pathway of the file I selected a second ago. Hence the step "set _PDFpath to _file". But I just can't figure out how to make FileMaker use that information to create the link to the PDF. Anybody knows how?

       

      Raynald

       

      Running FileMaker Pro 10 under Mac OS 10.6

        • 1. Re: Telling the finder to move a PDF to a new folder prior to creating a link to FileMaker
          FentonJones
            

          FileMaker has a slightly different path syntax from AppleScript (Mac)* paths. It has a prefix "filemac:/" for absolute paths, and the directory separator is "/" (not ":"). I recently created this little subroutine to convert them. Example (you'd use your AppleScript Mac path instead of the 1st 2 lines; mine below is the path to your iPhone xml data file, which has all the paths to the pictures):

           

           

          set picts_path to path to pictures folder as text

          setxml_pathtopicts_path & "iPhoto Library:AlbumData.xml"

           

          set FM_path to "filemac:/" & my ConvertPath(xml_path)

           

          on ConvertPath(Mac_path)

          set AppleScript's text item delimiters to ":"

          set x to Mac_path's text items

          set AppleScript's text item delimiters to "/"

          set z to x's text items as text

          set AppleScript's text item delimiters to ""

          return z

          end ConvertPath 

           

           

          You can just set the resulting FileMaker syntax path (could also be "imagemac:/" if you want to see the PDF) into a FileMaker cell (of the current record); for a reference to the file.

           

          *There are also Unix paths on a Mac. Which use the slash. But don't include the drive name (which you really should have in the path). They can also be converted, by having the Finder (or System Events) get the startup disk name and tacking it on the front.

           

          Basically each syntax path can be converted to the other. Conversely most non-simple operations integrating different scripting systems seem to require different syntax paths somewhere. Just one of those things :-]