Separate/import e-mail attachments for better search V2

Thank you @AWD and @mdbraber for this great work!

I’ve tried getting it to run, but I always stumble on some permission issues: Finder asks me to grant it some higher privileges with Touch ID, which I grant, but apparently I don’t grant enough, since I get the error:

	move alias "Macintosh HD:Users:me:Datenbanken:EmailsDevonThinkDB.dtBase2:Files.noindex:rtfd:e:Einladung.rtfd:bild.JPG" to alias "Macintosh HD:private:var:folders:6b:98zkkkjs1tl4xwid31r84woh0000gn:T:TemporaryItems:" with replacing
		--> current application
		--> error "Die Aktion konnte nicht abgeschlossen werden, da du nicht die erforderlichen Zugriffsrechte hast." number -5000

I gave DT4 full disk access, but I suspect there is no link between the two, since this is in the Finder part.

If you have any idea how to get it to work, that would be great!

Just for the record, since the question appeared in the conversation, here are my reasons why I’d like to use this script instead of the built-in functions (and I’d much rather have the built-in functions do it than fiddle with several scripts):

  1. Separate attachments are treated with OCR and are therefore searchable
  2. With the treatment of this script, there is a backlink between the file and the email (not with the inbuilt function)
  3. In addition, the email and the attachment are grouped together (not with the inbuilt function)
  4. When the attachment gets actually removed from the eml, this allows for space savings through deduplication (e.g. all the forwarded mails with attachments will otherwise take up much more space)
  5. Search works better in separate attachments, even indexed ones (shows where the search text was found)
  6. The file names of separate attachments can be found when searched for (currently, the filenames are not indexed when inside a message)

Have a great day!