File Name length limit (mail import/archive)

I am using the Mail archive function and frequently import mails to certain project groups in DTP3.

Recently I have started off-site backup with IDrive, which seems to have a limit to the file name length.

Some of my mails get very long file names when archiving and therefore cause errors in the backup process. Is there a way to trim the length during archiving?


Did you have a look at the Truncate Filenames script which is available via the Support Assistant?

Thanks for giving this advice. I have imported it and read it, seems to be exactly what I need.

It is stored in smart rules folder, I cannot assess it via DTP3 at the moment but just from the Finder (the location was given in the alert in the toolbar when imported). I have not yet worked with smart rules via Apple Script and will try to set it up tomorrow. Maybe, I will have some more questions… So far, it is evening in Japan…

Now, I have set up a rule and tested archiving mails with this rule.

In the beginning, I set it up to process after import like in this screenshot.

But this caused an endless delay, so I aborted the process already during the first import. Now I process the smart rule manually after import like in this screenshot. Works great, the backup produces no more errors.

Now, there are two problems that I am concerned with:

(1) Shortening file names from indivicual Mails from exhaustive threads may cause indentical file names, if I understand correctly. As of yet, I have not come across any problem, but I fear that the script may need pre-cautions for this case, correct?

(2) Apple Script is a bit slow. Could we have an option in the email archiving process that shortens long file names created from mails and that deletes certain problematic characters from these titles?

So far, everything works, thank you,

  1. Identical filenames are not an issue inside DEVONthink, as far as name collisions go. And even if there was a collision in the filesystem inside the database- the file would have an incrementing number appended to it behind the scenes.
  2. Slow in what way?
  3. Do you have Preferences > General > More compatible naming of files enabled?

Yes, an essential feature for me to use DevonThink for 19 years. But I am preparing these data for external backup. The system only sees the file structure and file names; therefore, it complained about file names being too long. This occurs when the Mail “Betreff” (topic) is very long.

I canceled the process after about 15 minutes, and it seemed to be in a loop or just processing hundreds of emails.

Yes, but now I understand that the problematic files were from databases I created years ago and only archived. So, no problems to expect from now on.

The maximum file name size nowadays seems to be 255 characters. Which looks like a lot to me.

Do you really have email subjects longer than that? If so, are they perhaps related to chains of “Aw: Aw:…” at the beginning, due to Microsoft’s ignorance of email standards? In that case, you could perhaps replace all those with a single standard-conforming "Re: "

The subjects are as long as I wrote.

As an aside…


Thank you for hinting me to another excellent post.

Unfortunately, it has nothing to do with my problem.

My problem is mail subjects of immense length from emails I receive and need to archive in bulk.

My concern about identical file names in the offsite backup stays unanswered.


Did you run the Tools > Batch Process > Execute Script: Truncate Filenames on files with long names as suggested above?

I set up the smart rule.

I used the script from the navigation panel (just below the smart folders).

I did not use the Tools menu. – The Tools menu needs me invoking the rule, in the beginning, I had set up the rule to process during import, which would be most comfortable. But this caused a terrible delay in the import process, as I wrote above.

I invoked the script manually, which should be identical to “Tools - Rules - Apply Rules”.

So, did you find an answer to my question in this post (File Name length limit (mail import/archive) - #4 by Maria)?

It is question no. 1 near the end of the post in particular.

Of course, an answer to question 2 would be appreciated as well. Since you asked, “Slow in what way?” in this post (File Name length limit (mail import/archive) - #5 by BLUEFROG), I can only state that it is slow in the meaning of slow in execution, thought that would be obvious.