Problems creating tags for my project


I’ve been using DTPO and now DT3 since a long time, and I’ve collected some 10 GB worth of documents. I’ve consistently named my records using this nomenclature:

  • YYYY-MM-DD - DocType, Source, Regarding

For the most part, documents have been handled by using basic scripting and Hazel before being importing into DTPO/DT3 to achieve this. During the last say half year, I’ve been doing this manually instead.

Most of the documents have tags corresponding to the nomenclature, i.e. if the record is named 2019-01-27 - kvitto, grab, taxi, it would the tags “kvitto”, “grab” and “taxi”.

Furthermore, Hazel was used to add comments to the files before import, creating this:

What I’m trying to achieve

  • I now want to group these records in a tag structure, using AppleScript and a test database. Progress have been made. This makes me able to find say, all documents, which are receipts, like so:

  • It’d also help to suggest new file names for newly imported files using the AppleScript compare command. I then hope that I could script on to get relevant suggestion for the DocType, Source, and Regarding part of the file name. I realise that this depends on the current organisation of files, but I still think that would be a more intelligent way, by harnessing DEVONthinks built in functionality, compared to my current Hazel workflow.

  • This could be further used in conjunction with e.g. OmniFocus to create tasks for certain DocTypes, etc.

My current problem
I’m currently scripting to sort present tags into the corresponding tag groups. But I’ve discovered that for some records I will have to create new tags, likely because they were not processed by Hazel before import.

I’ve been struggling to script in order create a tag group in my database.

  • I’ve been trying to compare with this good article on how to interpret the AppleScript dictionaries.
  • I’ve been out of luck searching this forum.
  • I’ve tried googling.

So please, help me out. This seems quite fundamental and if I can understand it, It’d make my life simpler. These are some of the attempts in trying to create the tag group:

tell application id "DNtp"
	if selection is {} then
		-- if no selection is made, process all records of the database
		set recordList to every record of current database
		-- If a selection is made, process selected records
	else if selection is not {} then
		set recordList to selection as list
	end if
	tell current database
		set theLocation to tags group
		-- set theNewTag to make new child of theLocation whose name is "test2"
		-- set theNewTag to make new tag group at theLocation with properties {name:"test2"}
		-- set theNewTag to make new record at theLocation with properties {name:"test2"}
	end tell
end tell


Here are two simple examples:

tell application id "DNtp"
	set theDatabase to current database
	set theTagsGroup to tags group of theDatabase
	-- This checks whether there's already such a tag
	set theTag to create location ("/" & (name of theTagsGroup) & "/Test1") in theDatabase
	-- This creates always a new tag
	set theTag to create record with {name:"Test2", type:group} in theTagsGroup
end tell

Thanks a lot for the fast support, works like a charm. Now I can continue.

Just out of curiosity. Regarding the dictionary, please see below, I cannot call on commands in the “Standard Suite” to make a new object. Did I use the wrong syntax? If not, why is this then referred to in the dictionary if I choose the dictionary for DEVONthink 3? Would that be applicable for other objects, I’m guessing windows, etc.? What am I missing?

Best regards,

“make” isn’t supported by databases & their records, only by standard objects (and by reminders). There are dedicated commands to create databases or records.