Tagging all content within a Group

I use DTPro/DTTG as a task manager using a “Getting Things Done” mentality. I create a new note (text or RTF) with the title being the task and then label the task “Now”, “This Week”, “Someday/Maybe”, “Waiting On”, etc. I also apply a tag called “task” to the note. I then create smart groups using criteria to filter such as “Tag: task AND Label: Now” which allows me to see all current tasks that need to be completed.

For the most part, I add all tasks to a Group called “Tasks”. However, I do tag documents in other folders with a “task” tag.

Though I am very new to AppleScript, I am certain that I can assign an AppleScripto the “Task” group which will automatically tag all documents in the “Task” group with the “task” tag to make my SmartGroups work properly.

Based on my current understanding of AppleScript and DTPro, I would need to manually click on the containing group call “Tasks” in order to execute the AppleScript. Therefore, unless I manually clicked the containing group, no new documents added to the Group “Tasks” would be tagged appropriately. It would make much more sense if there was a trigger assigned to the group that ran anytime any new content was added to the Group. Is this possible?

In addition, I plan to create task documents using DTTG which would then sync to the tasks group on DTPro. Of course, I would want these docuemnts automatically tagged when syncing with DTPro (again, I would not be clicking the Group “Tasks” that would trigger the AppleScript to run. Is this possible?


No, it’s not possible. Triggered scripts require interaction.

An Applescript isn’t necessarily needed.
Tagging a parent will tag its children automatically.

Also, you could look at Group Tags where files in a Group will be tagged with the name of the parent. You’d need to uncheck Exclude Groups from Tagging in File > Database Properties > …

I achieve a similar result using the following script, which I keep in my DEVONthink Toolbar. (Compile the script and insert it into ~/Library/Application Support/DEVONthink Pro 2/Scripts/Toolbar. Relaunch DEVONthink then add the script to any toolbar using View > Customize Toolbar…)

This script can be customized, but what it does is to add the tag defined in p_WIP to the currently selected document and change the label of that document to label #3, which I have defined in DEVONthink Preferences as “WIP (Document)” – WIP is “work in progress”. These parameters can be customized to fit your needs. The script is a toggle: if that tag and label are not set, then the script sets them; if they are set, then the script unsets them. Because each database has a group I named “Work in Progress” and that group is always set to be a tag, then this script automatically replicates / de-replicates the selected document to that group. Voila – I can look in “Work in Progress” and see what needs to be addressed.

property p_label : 3
property p_WIP : "Work In Progress"

tell application id "DNtp"
		-- if the selected item is not WIP then make it WIP
		if label of content record is not p_label then
			set theTags to tags of content record & p_WIP
			set the tags of content record to theTags
			set label of content record to 3
		end if
		-- if the selected item is WIP then make it not WIP
		if label of content record is p_label then
			set theTags to tags of content record
			set cleanedTags to my cleanList(theTags, p_WIP)
			set the tags of content record to cleanedTags
			set label of content record to 0
		end if
	end try
end tell

on cleanList(thelist, v_Remove)
	set newList to {}
	repeat with i from 1 to count thelist
		if ({thelist's item i} as string) is not equal to v_Remove then set newList's end to thelist's item i
	end repeat
	return newList
end cleanList

Thanks both of you for the reply.

I ended up tagging the parent group since this step then automatically tagged all the children documents, exactly the behavior I was looking for.

I have created SmartGroups that look similar to this:

tag: tasks AND label:now
tag: tasks and label: waiting-on

In this way, I can easily filter my tasks using the SmartGroup.

No problem. :smiley: