Script: Import mail attachments filtered by MIME type

I actually didn’t check whether it would be possible via do shell script because calling anything via do shell script is quite slow. It’s not bad if it’s called few times in a script but as soon as you use it in a repeat it really adds up, so I avoid it if possible (and writing my own makes sense and I can do it). However in this case there’s no real speed difference.

To escape strings use quoted form of . I’ve also added the -b flag

set theAttachment_MIMEtype to do shell script "file -b --mime-type " & quoted form of theAttachment_TempPath

How exactly do you plan to use the MIME type in your script? In a mail rule? In my tests I excluded images which then imported 100 attachments instead of around 400 without filtering. But I’m actually not sure where to use it.