sflynn Posted June 23, 2008 Posted June 23, 2008 I am storing some word doc files and some text files in container fields to keep them part of a larger project. I would like to write a script or something that would automatically open up that file, and copy the text and put it into another field so that I can run some scripts on the acutal text. I have the scripts working to sort and pull data from the text, but I want to eliminate the manual process of opening the file, copying the text, and then pasting it into the other field. Any thoughts out there?
Fenton Posted June 24, 2008 Posted June 24, 2008 (edited) AppleScript can do this, using the shell command "textutil" (which can read and convert lots of things, incl. html). Most of the below code is to do with getting the file paths and/or converting them from Mac to Unix. For what you want to do, you would have to convert your FileMaker export path to Unix, which is actually easier; especially since you could do the calculations within FileMaker for the path and file name(s); in unstored fields (no bloat -). It will write the file into FileMaker as text. It will not do Word tables as tables, just text. (There was a post here a while back which shows how to get Word tables using Linux, but not Mac, AFAIK.) I'll do an example of export/convert/read Word file in a FileMaker container later. But right now I've got to do some real work. Sigh. set Mac_file to choose file with prompt "Choose a Word or rtf file" tell application "Finder" set file_name to name of Mac_file set theExt to ("." & name extension of Mac_file) set name_only to my nameOnly(file_name, theExt) end tell set txt_file to quoted form of name_only & ".txt" set Unix_file to quoted form of (POSIX path of Mac_file) set fold to quoted form of (do shell script "dirname " & Unix_file) set txt to do shell script "cd " & fold & "; textutil -convert txt " & Unix_file & "; cat " & txt_file -- Will create new converted file, with extension ".txt" at location, then read it tell application "FileMaker Pro Advanced" set cell "txt" of current record to txt save record end tell on nameOnly(fileName, ext) set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ext} set theName to first text item of fileName as string set AppleScript's text item delimiters to TID return theName end nameOnly Word_as_Txt.fp7.zip Edited June 24, 2008 by Guest Sigh
Recommended Posts
This topic is 5997 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now