Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6624 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a folder full of email files. I have an applescript that changes all the extensions to .txt so I can import them into my FMP file. I have two fields in my FMP file, the filename and the email text.

Everything works perfectly except the carriage returns that are in the email text seem to evaporate, making all the text run together.

I had done this same thing using email files from Entourage and all the carriage returns came over in the import. I am now trying to do the samething with email files from Mail and though I can see that they are there in the email files, they are not there when imported.

Any ideas? I am frustrated that it worked before with the other email system but doesn't work with this one.

Posted (edited)

Here is a technique to convert the line endings. I'm taking it from this info about AppleScript and the shell, from the Apple site:

By default, do shell script transforms all the line endings in the result to Mac-style carriage returns ("r" or ASCII character 13)...

This means, for example, that the result of do shell script "echo foo; echo bar" is "foorbar", not the "foonbarn" that echo actually returned. You can suppress both of these behaviors by adding the without altering line endings parameter.

I'm using "read" to get the contents of the file. It does not care whether its extension is "txt" or "emlx" (Mail). So I'm getting both.*

There is both an AppleScript file, just for viewing the full script (in pretty colors :-), and a FileMaker script, using Perform AppleScript. The script inside FileMaker is both shorter and faster.

The reason I put the tell app "FileMaker Pro Advanced" inside its own subroutine is so you don't have an FM tell inside a Finder tell block. So the tell FileMaker can be removed for Perform AppleScript.

* I realized that it is actually 2 steps to "read" with AppleScript, then convert with do shell script. It can be done in 1 step by reading the file with the shell command "cat". So this new file has both (I hope). They seem to both be fast; can't tell which is faster.

Unix_Text_files.zip

Unix_Text_files.zip

Edited by Guest
added cat
Posted

Fenton,

You are wonderful!! It works exactly like I want it to work. You helped me save hours of work!!! I wish I understood everything you did in that Applescript! But I know it works. Thanks again.

Bev at Our Town

This topic is 6624 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.