Copying only specific data - but containing the folder structure


let’s say I have a database with a group INVOICE. In this group I have subgroups like CAR, HOUSE, WORK etc. In this subgroups I save PDF-invoices, that have a name like YYYYMMDD Title. Or if needed I can also tag them with “YYYY TAX”

For doing the tax delaration at the end of the year, I would like to copy all replicants within a certain timeframe (e.g. all invoices of 01-01-2020 until 31-12-2020) or all invoices with a certain tag (e.g. “2019 TAX”) to a new group TAX, but the subfolder structure CAR, HOUSE, WORK should be maintained… which means, that in the TAX group, these subgroups should be created and all original files with either date or tag condition should be copied there as replicants…

I am quite sure this is possible with DTP3… Does anyone of you have a good idea, how this might be solved with smartrules? or do I need applescript for it? Or does anyone have already such a usecase and has solved it in a better way…

Thanks so much for your ideas…

The easiest approach coming to my mind is to copy the group first. Then use the advanced search to search only in this group for those items which should be removed and finally trash them. But I would suggest to try this using dummy data or a dedicated database first.

Like so…?

No… something like this…

Based on a tax group with multiple subgroups, only certain files are copied as replicants to a new tax folder (either based on date in the file name or based on a manual tag)

Those aren’t replicants. :question:

And I don’t see how that’s functionally different from what I showed.

in your example in the 2019 Taxes smartgroup the subgroup structure is missing…

The smart group was incidental and just used as a potential source for running a script.

great, yes, then you have fully understood what I am seeking for…the approach of @cgrunenberg is fine and works, but maybe there is a way to automate such things?!

property taxUUID : "5A3D3C72-872C-44C9-BFC5-981D89CC4EEF"

set ot to AppleScript's text item delimiters

tell application id "DNtp"
	set taxGroup to get record with uuid taxUUID
	repeat with thisRecord in selection as list
		set recordLoc to location of thisRecord
		set AppleScript's text item delimiters to "/"
		set recordGroup to item -2 of (text items of recordLoc)
		set newLocation to create location ("/Taxes 2019/" & recordGroup as string) in current database
		replicate record thisRecord to newLocation
	end repeat
end tell

set AppleScript's text item delimiters to ot

You’d need to replace the UUID with the UUID from the item link of your Taxes 2019 group.

wow… this seems to be a great approach… I have never used a script before (and tried to understand how to use them with the manual). can I use this script in a smart rule? or what is the correct approach? I would be really thankful for a short explanation how to implement this script in DT…

  1. Unzip the attached file.
  2. In the Finder, press Command-Shift-G and paste: ~/Library/Application Scripts/com.devon-technologies.think3.
  3. Drag and drop the AppleScript from Step 1 into the Menu folder in this window (or a desired subfolder).
  4. Relaunch DEVONthink and you can access the script from the Script icon menu (and the subfolder, if chosen).

Optionally, if you put the script in the Toolbar folder in step 2 above, you can…

  1. Relaunch DEVONthink.
  2. Right-click the toolbar in DEVONthink and choose Customize Toolbar.
  3. Drag and drop the AppleScript to the Toolbar.

DT File (2.8 KB)

It is technically possible to use a version of this in a smart rule, but it would have to make changes to avoid reprocessing the same files again.