6 Replies Latest reply on Jul 20, 2013 1:35 AM by macmesser

    outputting a text file for each record

    macmesser

      Title

      outputting a text file for each record

      Post

           Can Filemaker Pro save a text file for each record so that the filename and content of the file is a formula based on  the record's field values? Pretty sure this could be done with an Applescript. Doable with Filemaker Pro itself? I have advanced.

        • 1. Re: outputting a text file for each record
          philmodjunk

               If you set up a calculation field to pull all of that data into a single field, Export Field contents could then be used to export the data as a text file. Your text encoding options are limited, however so you may or may not be able to get that to work.

               That same single field can also be exported with export records and if you limit your found set to one record, then you'll get a text file for a single record, but now you can select additional encoding options for the exported text.

          • 2. Re: outputting a text file for each record
            macmesser

                 Thanks. I want to export as HTML file, one HTML file per record. I'm guessing that would be a common encoding and supported by Filemaker Pro. Is there an option with exporting field contents for naming the exported file with a calculation?

                 Selecting each record and exporting would be kind of unwieldy. I believe I would have to enter the filename manually as well, which defeats my purpose of automation.

            • 3. Re: outputting a text file for each record
              philmodjunk

                   Export field contents offers no such option. You'd have to export from a field that had the HTML tags specifically added.

                   Using Export records is not nearly so unweildy as you think. A script can do the whole thing, even specify the file name for each such exported file, but you still have that requirement for HTML formatting. There is an option with export records where you can specify HTML files, but I don't think that will supply the needed HTML tags to the data--but have never used that option.

                   You may need to experiment with exporting from a calculation field (test with both export options) or that uses GetAsCSS to provide the needed formatting tags.

              • 4. Re: outputting a text file for each record
                macmesser

                     Thanks for reply. I understand that the tags need to be created with Filemaker Pro fields. I was referring to the text encoding being HTML compatible by default.

                     Looking at the "export records" script step I see no way to programmatically name the exported HTML files, except by hard coding a name which would be the same for every HTML file exported. I would want to name the HTML files based on a field calculation for each record. How could that be done?

                • 5. Re: outputting a text file for each record
                  philmodjunk

                       To have a script supply the file name, You set a variable to text that specifies the file path for the file to be created. The file path will specify the location and the name of the file to be created. Then you type the exact name of this variable, without quotes, in the dialog where you would otherwise specify the file and location for the export.

                       This technique may be used with both Export FIeld Contents and Export Records. See this thread for more info and an "exploration file" on the subject: Exploring the use of a $Path Variable in Scripts

                       I'd try using export field contents first and specifying the needed file extension for an HTML file to see if that works. As far as I know, an HTML file is just a simple text file with the HTML file extension.

                       If that doesn't work, I'd try exporting to a file of type text, but with the correct file extension using Export Records.

                  • 6. Re: outputting a text file for each record
                    macmesser

                         Thanks! Just what I needed. HTML is just a plain text file so this should work fine.