I give up on manually filing all my documents..need advice on automating, filing and storing documents in devonthink :)

@BLUEFROG this works great in safari, but cant seem to find the save pdf to DEVONthink 3 option in chrome based browsers (chrome,brave) is there a solution for that?

To solve your issue (and many others behind the scenes) stop using Chrome and Chromium browsers :wink:

Actually, this is not a DEVONtech issue but one of those browsers. They decide they like to use their own print dialogs instead of behaving in a proper Mac-like manner. And their answer is to use Option-Command-P to use the system print dialog. So my tip still works, but it’s Option-Command-P followed by Command-P.

PS: Once more for those in the back: stop using Chrome. :smiley:

Sorry for the late reply.

[Edited for accuracy]I use one iOS shortcut and one script for this

iOS Shortcut - Receipt Process
It asks for some name and amounts and categories, then adds that info as comments and adds it to DEVONthink.

Then I use the script below via a smart rule to extract the comment field to metadata fields. You’ll have to line up your field names and change all the database destinations for it to work.

CAVEAT:

I’ve pieced this together using other peoples work and all while learning a bit of code here and there. I am not a professional code writer by any stretch. use at your own risk. I am also constantly revising and improving things as I learn more.
Suggestions for improvement gratefully accepted

set od to AppleScript's text item delimiters
tell application id "DNtp"
	set theRecords to (selected records) -- THIS IS WHERE THE VARIABLE IS SET IN THIS STANDALONE VERSION. REMOVE OR COMMENT OUT THIS LINE FOR USE IN THE SMART RULE**strong text**
	# set AppleScript's text item delimiters to (ASCII character 13) --// CR
	set theComments to {}
	repeat with thisRecord in theRecords
		set AppleScript's text item delimiters to (ASCII character 10) --// LF
		set theComments to (comment of thisRecord)
		# if (count theComments)=>1 then
		set eachLine to text items of theComments
		repeat with theitem in eachLine
			set AppleScript's text item delimiters to ": "
			set values to text items of theitem
			#return item 2 of values
			set attribs to (text items of values)
			if (count attribs) = 2 then
				set val to item 2 of attribs
				set theKey to item 1 of attribs
				if (theKey as string) = "tip" then
					set theKey to "tiprec"
				end if
				if (theKey as string) = "vendor" then
					set theKey to "vendor"
				end if
				if (theKey as string) = "Date" then
					set theKey to "daterec"
				end if
				if (theKey as string) = "hst" then
					set theKey to "gst_hst"
				end if
				if (theKey as string) = "Category" then
					set theKey to "categoryrec"
				end if
				if (theKey as string) = "Total" then
					set theKey to "amount"
				end if
				add custom meta data val for theKey to thisRecord
			end if
		end repeat
	end repeat
	set AppleScript's text item delimiters to od
end tell
1 Like

Can you post an example comment you’d be processing?

Here’s one sample:

tip: 1.53
hst: 0.21
Total: 10.41
vendor: Noctua Bakery
Category: Restaurant
Date: 2024-09-21

I can modify how that comment field is created using my shortcut. I eventually want to add more lines to it to match more of the metadata fields that I have (tax category and subcategory being two) For the moment though the fields in there now are the fields that are the most work intensive to extract accurately and are the most top-of-mind when I am “in the field” staring at my phone or on a bus or waiting for a train or a friend or a doctor.

1 Like

Likewise, my receipts data is stored/organized in Devonthink
Collection on my mobile device; no shortcut - I do all processing on my Mac, assisted with an AppleScript

I have another script, run monthly to extract the receipt data and load the Transaction Register of my budget spreadsheet

Here is my rewrite based on your example comment…

tell application id "DNtp"
	my performSmartRule(selected records)
end tell

on performSmartRule(theRecords)
	set od to AppleScript's text item delimiters
	tell application id "DNtp"
		repeat with theRecord in theRecords
			if (comment of theRecord) is not "" then
				set theComment to (comment of theRecord)
				repeat with theLine in (paragraphs of theComment)
					set AppleScript's text item delimiters to ": "
					
					(* abbr is the text from the comment; theKey is the custom metadata's name *)
					repeat with attrib in {¬
						{abbr:"tip:", theKey:"Tip"}, ¬
						{abbr:"Total:", theKey:"Total"}, ¬
						{abbr:"vendor:", theKey:"Vendor"}, ¬
						{abbr:"Category:", theKey:"Category"}, ¬
						{abbr:"Date:", theKey:"Transaction Date"}}
						(* You can add other abbreviations and attributes, as needed. *)
						
						if theLine begins with (abbr of attrib) then
							set theVal to (text items -1 thru 2 of theLine) as string
							-- log theVal to verify the item being parsed
							add custom meta data theVal for (theKey of attrib) to theRecord
						end if
					end repeat
					set AppleScript's text item delimiters to od
				end repeat
			end if
		end repeat
	end tell
end performSmartRule

Bear in mind, this is my approach. It’s not a right or wrong thing. And nested lists are a bit more advanced AppleScript concept but they can be very useful.

PS: The Option-Return symbols are optional and just for legibility of the nested list.
PPS: My version works as a standalone or a smart rule script.

5 Likes

This would all be moot if Custom Metadata was available to manipulate on DTTG. Hint hint.
But I get it, there’s a lot of items on the features to add list. Not even sure if this would be my number one request but it might be in the top two.

1 Like

Perhaps a good reason to use Tags and Labels where possible, instead of Custom Metadata

edit;
For receipts, I use a set of Vendor tags, and a set of Budget-Category tags
Using the record comments is an interesting workaround for the DTTG issue

1 Like

I respectfully disagree.
I’ve got a system on desktop that works and an iOS system that feeds it. As I explained earlier I can feed into the desktop metadata system through this system of finder comments and make use of the time I have with only my phone available.
It’s extensible and I could repurpose it to other kinds of documents than receipts in other databases than financial.
Then again this is DevonThink. It can be many things to many people.

1 Like

Always good to see how more the far more skillful ‘scripters do it. Thanks. Will investigate.

1 Like

Different concepts, imo. Tags convey one value (mainly, even in the case of hierarchical tags) – they are assigned or not assigned. Metadata can store any number of values. EG, a single metadata containing a country code is easier to use than 196 (or however many we have now) single tags, each containing a country code. And for this thread: none of tip, total, vendor, or date lend themselves to tagging.

3 Likes