Hi,
Here’s the script I have that is supposed to…
- Find files from a specified folder that do not have specific text in the Spotlight Comments.
- Get the text of each file, create a new Filemaker record, and put the text of each file into a Filemaker field.
The files are .emlx. I run into problems when an email file has attachments. Any ideas on how to get around the issue? What I really need from the .emlx file is the header and body. So that would be an alternative approach, but I’m not sure how to get that, based off of the emlx filepath and filename.
Help?
global theName
global fixContents
tell application "FileMaker Pro Advanced"
tell window 1
set theFolder to field "Folder" of current record as alias
end tell
end tell
tell application "Finder"
try -- because alias list won't work if there is only one file.
set theFiles to (every file of entire contents of theFolder whose comment does not contain "TheText") as alias list
on error
set theFiles to (every file of entire contents of theFolder whose comment does not contain "TheText") as alias as list
end try
if theFiles is not {} then
repeat with theFile in theFiles
set theName to name of theFile
set theContents to read theFile
try
set fixContents to do shell script "echo -n " & quoted form of theContents
end try
-- -n suppress the extra line
-- 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 newRec to the ID of (create new record)
go to record ID newRec
set cell "filename" of current record to theName
set cell "email text" of current record to fixContents
save record
end tell
end tell
end FM_Create_Record