rlinsurf Posted October 17, 2009 Posted October 17, 2009 Yes, I can import html files by using the Import-->File...-->Tab-Separated. But when I try this with a folder, FM gripes it isn't the right file format. I need to automate this process, as I have several hundred pages to import and parse out. Is there a way to do this?
fseipel Posted October 18, 2009 Posted October 18, 2009 (edited) I would recommend the ScriptMaster plugin's example function 'list all files in a directory'. That will generate a list of all files in the folder. Storing said list in a field, you can then get individual filenames/lines from this list, using the GetValue(line#) function, and import them one by one in a loop. You may need to do a global substitution with the Paragraph symbol for CRLF's prior to using GetValue. You can then import each file sequentially. Alternately an AppleScript, Troi File plugin, or shell command can be used to generate the directory listing instead of ScriptMaster. If you want to do this in two lines of code, perhaps issuing a single shell command to append all the files to a single file, followed by an import, would be best. i.e. cat path*.html path2combined.html where cat = concactenate shell command under OSX. That would combined all files in path which end in html, to the single file combined.html. You can run the shell script via an AppleScript OR using ScriptMaster. Edited October 18, 2009 by Guest
Fenton Posted October 18, 2009 Posted October 18, 2009 A variation of fseipel's AppleScript idea, but to do each file separately. global aName global aContents set aFolder to choose folder -- you could use a fixed folder instead tell application "Finder" set file_list to (files of aFolder whose name extension is in {"txt", "emlx", "htm", "html", "log"}) as alias list -- "emlx" are default Mail files if file_list is not {} then repeat with aFile in file_list set aName to name of aFile set posix_file to quoted form of POSIX path of aFile set aContents to do shell script "cat " & posix_file -- do shell script converts Unix to Mac returns my FM_Create_Record() end repeat end if end tell on FM_Create_Record() tell application "FileMaker Pro Advanced" tell window 1 set new_rec to (create new record) set cell "Filename" of new_rec to aName set cell "Contents" of new_rec to aContents end tell end tell end FM_Create_Record Read_Files_of_Folder.fp7.zip
Recommended Posts
This topic is 5515 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