9 Replies Latest reply on Apr 30, 2016 12:21 AM by erolst

    How can I import Word documents

    TheNovice

      Hello,

      I work with FM 14. I store newspapers articles in table X. My layout is based on that table and it has different fields where the details of the article are inserted, plus a portal where I store the newspaper article(s).

      Here is my question: I have thousands of newspapers articles in Word format in a folder on my C: drive that date back to before I built my FM database. I want to write a script that will do the following:

      1.    Starting from my layout, create a new record (easy enough);
      2.    Go to the appropriate folder on my C: drive where the Word articles are stored; (I have no idea how to do that)
      3.     Grab the first article; (no idea how to do that)
      4.     Go to the first empty portal field (Go to Field???);
      5.      Insert the article (the file) in that field (not sure how to do that)
      6.      Repeat a. to e. until the folder on my C: drive is empty.(no idea how to do that)

       

      Is this feasible? Thanks for your help.

        • 1. Re: How can I import Word documents
          Extensitech

          Do you want to insert the word files into container fields (Insert File script step) or insert the text from the word documents into text fields?

           

          For identifying all files in a folder and looping through them, I'd check out 360Works ScriptMaster. It's a free plugin that's sort of a "swiss army knife", and if I'm not mistaken, the functions you need are included as sample plugin calls.

           

          If you want more granular control of what you pull out of each word file, you may also want to check out their Scribe plugin. We use it and love it.

           

          HTH

          Chris Cain

          Extensitech

          • 2. Re: How can I import Word documents
            Karen

            I'd be wary of only inserting or pasting text unless you are sure all Word documents are purely text. The text field happily supports Rich Text, but the Word files could contain more complex formatting that would be lost (tables, columns, images).

            I once set up a database to store archived emails in — and while of course dropped the text into a searchable field, I also stored the .EML on the file server (container ref) for original viewing and attachment extraction.

            So for peace of mind, you may need to do both container and searchable text field, perhaps not bothering to retain rich text, saving a little space.

            • 3. Re: How can I import Word documents
              TheNovice

              Thanks for your answers,

               

              I want to insert the Word files into the container field in the portal. Still not sure what the script should look like.

              • 4. Re: How can I import Word documents
                erolst

                TheNovice wrote:

                1. Go to the appropriate folder on my C: drive where the Word articles are stored; (I have no idea how to do that)
                2. Grab the first article; (no idea how to do that)
                3. Go to the first empty portal field (Go to Field???);
                4. Insert the article (the file) in that field (not sure how to do that)
                5. Repeat a. to e. until the folder on my C: drive is empty.(no idea how to do that)

                 

                Is this feasible? Thanks for your help.

                The usual idea would be to select a folder, read in a list of files (or more to the point, their paths), then process that list in a loop. This is perfectly feasible, though you would need a plug-in to read in the contents of an arbitrary folder. 

                 

                But before embarking on that endeavour (could be a nice exercise), first check the Import Folder feature; that lets you batch import files in a folder (and any sub-folders, if desired), where the necessary records are created automatically.

                 

                Next step would be to generate meta-data (categories? tags? abstract?), most likely from the file name or path components (as that is your only non-binary information at that point).

                • 5. Re: How can I import Word documents
                  Karen

                  Google is your friend!

                  here is an old thread explaining a possible process for Windows (I use AppleScript, so no help there)

                  Scripting import of multiple files in a folder - Importing & Exporting - FMForums.com

                  "You could with a plugin. (FileManipluator) or others.

                  You would choose a folder or directory the plug-in would grab the path to that location.

                  The plug-in could grab the file listings of that directory, then with that data in a variable,

                  you could process down the list of file that will import a directory of excel files."

                   

                  AKA; If you had the dump of file paths to the directory, you could run through the file list, one value line at a time.

                  Take a look at the samples from plugins, as writing a script of this nature may be reinventing the wheel.

                  There are dozens of articles and posts on this topic, some suggesting plug ins, others getting into the custom scripting.

                  a few more articles for a home brew:

                  Without AppleScript, on Mac, I'd use Terminal for the dump and do the rest in FMP. These talk about getting the file list for Windows via their method:

                  Filemaker Pro - Multiple File Importing | DaniWeb

                  Importing Word Documents or PDF files [Archive] - FileMaker Forum | FMT FIleMaker Community

                  • 6. Re: How can I import Word documents
                    Karen

                    Sadly, Import Records; Folder still only works with Images or pure text (I know, right?)

                    But Insert FIle should do the job once a list of filepaths is made and parsed line by line into a variable for Insert File to use as path.

                    • 7. Re: How can I import Word documents
                      TheNovice

                      Thanks again for all your efforts. I must admit I find this quite complex for someone as computer illiterate as I am. But I'll do my homework and I'll get back to you.

                       

                      My life expectancy is only around 15 years, so this is why I need a script to import these word docs for me.

                      • 8. Re: How can I import Word documents
                        rgordon

                        I had initially thought of the Import from folder but according to the fm documentation it doesn't work with Word docs.  Are you sure you want to import the files into the database instead of just storing the file reference for the files.

                        • 9. Re: How can I import Word documents
                          erolst

                          Karen wrote:

                           

                          Sadly, Import Records; Folder still only works with Images or pure text (I know, right?)

                          Bummer … I thought it would work with any … well, folder contents.