5 Replies Latest reply on May 8, 2012 10:48 AM by philmodjunk

    Applescript vs. Plug-In

    kayakjunkie

      Title

      Applescript vs. Plug-In

      Post

      I have a solution that needs to perform file management.  (File Copy, File Rename, File Move, File Delete, List Folders, List Files in Folder, Select Files, Launch external applications, etc.)  This appears to be beyond the capacity of FMPA script capabilities.

      I've seen a number of plug-ins that provide such capability with varying degrees of ease of use, documentation, cost, etc.

      Am I generally better off using such plug-ins, or alternatively developing some skills working with Applescript?

       

      Jesse

       

        • 1. Re: Applescript vs. Plug-In
          Jason Wood

          I have no plans to ever use my databases on Windows, so I use AppleScript wherever I can.

          It used to be both for cost reasons and installation hassle, but plug-in installation can be automated in FM12 so that's less of an issue.

          Even if AppleScript doesn't directly do what you want - remember that you can also use it to run shell scripts.

          • 2. Re: Applescript vs. Plug-In
            philmodjunk

            FWIW, FileMaker scripts can do the first 4 tasks in your list. The only directories it can list, however are the documents folder and any folders contained within it.

            I avoid system scripts and plug ins whenever possible as they both can be broken by a future release of FileMaker, but as this post indicates, that is not always possible.

            • 3. Re: Applescript vs. Plug-In
              kayakjunkie
              Looking at the Scripts allowing for File Controls, it appears that the controls are limited to interacting with Filemaker Data files.  Is this correct? In my case, I need to download files from a broker-dealer firm that are compressed in either .exe or .zip files. These files need to be moved into a temporary work folder. Each file is then uncompressed.  There will typically be 2 - 5 files within the .exe or .zip file. Each file is comma-delimited with an extension that indicates the nature of the file. Example: files with the .TRN extension represent account transactions. /*It seems that FMP cannot import comma-delimited files unless they have a .CSV extension.  So each file needs to be renamed from ADYYMMDD.xxx to xxxYYMMDD.CSV in order for the nature of the file contents to be maintained as part of the file's name.*/ Each of the resulting files then need to be moved to a folder with other files of the same type, e.g. all TRN files together.  The original compressed .exe or .zip file then needs to be moved to an archive folder. Finally, based on a user-defined date range, I need to run looping FMP import procedure for each file type into the relevant tables. From what I've read, I need to look outside of FMP to generate these actions.  The question then is whether there is any consensus on the best way to approach these problems?  In some ways it seems attractive to code the needed functions directly in applescript.  However, given the time involved, it is probably faster to purchase a plug-in.
              • 4. Re: Applescript vs. Plug-In
                kayakjunkie

                Wow, doesn't this editor know about formatting?  Let's try again.

                Looking at the Scripts allowing for File Controls, it appears that the controls are limited to interacting with Filemaker Data files. Is this correct?

                In my case, I need to download files from a broker-dealer firm that are compressed in either .exe or .zip files. These files need to be moved into a temporary work folder. Each file is then uncompressed. There will typically be 2 - 5 files within the .exe or .zip file.

                Each file is comma-delimited with an extension that indicates the nature of the file. Example: files with the .TRN extension represent account transactions.

                /*  It seems that FMP cannot import comma-delimited files unless they have a .CSV extension. So each file needs to be renamed from ADYYMMDD.xxx to xxxYYMMDD.CSV in order for the nature of the file contents to be maintained as part of the file's name.  */

                Each of the resulting files then need to be moved to a folder with other files of the same type, e.g. all TRN files together.

                The original compressed .exe or .zip file then needs to be moved to an archive folder.

                Finally, based on a user-defined date range, I need to run looping FMP import procedure for each file type into the relevant FMP tables.

                From what I've read, I need to look outside of FMP to generate these actions.

                The question then is whether there is any consensus on the best way to approach these problems? In some ways it seems attractive to code the needed functions directly in applescript.  However, given the time involved, it is probably faster to purchase a plug-in.

                Are plug-in generally compatible with both OSX & Windows?  The ability to write a function or script once and have it work on both OS would have value.

                • 5. Re: Applescript vs. Plug-In
                  philmodjunk

                  Is this correct?

                  If you limited your efforts to options from the file menu, yes, but scripts have other options that can do file manipulation tasks.

                  Example:

                  If you use a container field, you can insert a file into the container field, then use export field contents to export the container to a specified location. Ergo, you have just copied a file from one location to another.

                  Example 2: export field contents with no field specified but a path and file name specified will delete the file.

                  In both examples, you can use a variable to compute the file path needed to get the results you want. And the path used to export the field contents can include a different file name and thus rename the file for you--changing the file extension to .csv for example.

                  And if you locate your folder of decompressed files inside your documents folder, this function:

                  Get(DocumentsPath)

                  can be used to get a return separated list of all files and folders (and their contents) in the documents folder. Thus, with a bit of scripting, you can get a list of all files for any folder found in this one standardized location.

                  The one thing you can't do, as far as I know, is decompress the files from a Filemaker script.