Rule to change thumbnail to custom png image

I’ve read several very old posts about this issue, but couldn’t find an answer that worked.

(Using DT3 Pro 3.9 on a Mac)

I’ve created some basic rules to add tags to .eml files upon import after they are sent to my Inbox from the DT3 “Add Messages to DEVONthink” Apple Mail Add-On. They work perfectly, but the one additional step I cannot figure out is how to change the thumbnail of those imported .eml documents to a custom png file.

Please note that I am NOT an expert on writing scripts, but I have tried using some suggested scripts to make this process happen. Here are two examples:

APPLESCRIPT:

on performSmartRule(theRecords)
	tell application id "DNtp"
		set theIcon to "/Users/phil/My Files/DevonThink Icons/Email Icon.png" -- replace with the actual path to your custom icon
		do shell script "sips -i " & quoted form of theIcon & " -s com.apple.Icon^M " & quoted form of thePath
	end tell
end performSmartRule

JAVASCRIPT:

function performsmartrule(records) {
	var app = Application("DEVONthink 3");
	app.includeStandardAdditions = true;
	tell application id "DNtp"
		set theIcon to "/Users/phil/My Files/DevonThink Icons/Email Icon.png" -- replace with the actual path to your custom icon
		do shell script "sips -i " & quoted form of theIcon & " -s com.apple.Icon^M " & quoted form of thePath
	end tell
}

These have both been tried from the “Execute Script” action within the DT3 rules. Neither of them actually added the custom icon, nor did they issue any kind of error message.

I can easily make any of these imported .eml files display my custom png image by simply showing the Properties of the document and pasting my image over the default icon / thumbnail image, so it seems like there would be a way to automate this same process.

Okay, enough rambling. Can anyone tell me how to do this?? I’d be extremely grateful for any help.

1 Like

Your second example is some strange mix of AppleScript and JavaScript. Not sure where you got this approach but it’s incorrect. Also, there is no need to use a shell command for this.
It’s a simple thing to implement…

  • Create a smart rule targeting a specific location where emails come in.
  • Set the Kind to Email.
  • Add a Date Added to Today or This Hour to avoid over- or reprocessing emails unnecessarily.

  • Add an Execute Script action with this simple script…
property emailIcon : "~/Downloads/email-messages-icon-16.png"

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set thumbnail of theRecord to emailIcon
		end repeat
	end tell
end performSmartRule

This yields results like this…

image

(The email icon in this case is via Email from freepnglogos.com)

1 Like

Wow, this is exactly what I needed, but as a non-programmer, I was struggling to figure it out. Thank you very much for taking the time to share this!! DEVONthink is changing my life in terms of how I gather and retrieve thousands of research documents… it is a phenomenal app!

Although what you did so far may have been suboptimal, I just want to say it’s impressive nonetheless. AppleScript, JavaScript, automation on the Mac, etc., are all very arcane and so incredibly fiddly that getting this far should be viewed as an achievement in its own right!

Thank you! I appreciate that very much.

You’re welcome.
I encourage you to continue investigating smart rules as they have many useful functions, even accessible to non-programmers. :slight_smile:

And thanks for the kind words about DEVONthink. Much appreciated.