2 Replies Latest reply on May 28, 2014 10:55 AM by mbust

    how to compress multiple files into one for send-email script attachments

    jhc

      Title

      how to compress multiple files into one for send-email script attachments

      Post

           In the FMP answers page there's a description of how to send multiple files as part of the send email script. 

           http://help.filemaker.com/app/answers/detail/a_id/323/kw/multiple%20file%20attachments

           But the article doesn't explain how to compress multiple files into a single one. Anyone know how to make filemaker do this?

            

           In my case I want the user to just tap on the iPad, and behind the scenes five excel spreadsheets are made. Instead of having to send him five emails I'd rather have it just send one email with a zip file attached which contains the 5 xlsx files.

        • 1. Re: how to compress multiple files into one for send-email script attachments
          philmodjunk

               I do not think that you can automate that for an iOS device at this time.

               In FileMaker Pro, you might be able to come up with a system script that FileMaker can run to zip the files into a zip archive. But that's not an option that will work on an iOS device such as an iPad.

          • 2. Re: how to compress multiple files into one for send-email script attachments
            mbust

                 Hello,

                 Here's a way to do what you want from FileMaker Pro, but not from the iOS. I run an adapted version of this script from within FM using the Applescript command so that I can send a single email with multiple files all compressed into one.

                 set ReplacingX to true
                 --tempStorage is where the files are temporarily stored to compress them. This file is emptied as the script begins to run
                 set tempStorage to alias "Macintosh HD:<<ADD HERE the Path to your tempStorage folder>>:TempStorage:"
                 tell application "Finder"
                     delete every file in tempStorage
                 end tell
                 set fileListX to {} -- you can easily collect this from FM.  I have the entire collection of files in a folder, and each FM record has a filename; thus I can create the file path for each record and with a loop, create the entire list.

                 set return_list to {}
                 repeat with aItem in fileListX
                     tell application "Finder"
                         activate
                     --Files are copied to the temporary folder before compressing them
                         set return_list to return_list & ((duplicate (aItem as alias) to (tempStorage as alias) replacing ReplacingX) as string)
                     end tell
                 end repeat

                 --The actual compression happens by way of the last line below, "do shell"
                 tell application "Finder"
                     set itemPath to quoted form of POSIX path of tempStorage
                     set fileName to "AutomaticArchive.zip"
                     set theFolder to POSIX path of (tempStorage as alias)
                     set zipFile to quoted form of (theFolder & fileName)
                     do shell script "zip -jr " & zipFile & " " & itemPath
                 end tell
                  

                  

                 Then all you need is the path to the AutomaticArchive.zip file which contains all the files that were compressed.

                 I know this is not exactly what you wanted, but I don't think iOS can compress files the way you want it.