Proper syntax for using @Destination in DT 3.62?

I would appreciate some assistance with the correct syntax for use of @Destination to send an item to a named group. If the item’s name is Credit Card Statement and the target group is Credit Cards within the Financial database, what would the proper syntax be?

Thanks for any assistance…

The syntax is just @groupname. By default the script looks only in the current database for a group with the specified name, this can be changed by setting pGlobalSearch in the script to true.

Thank you, @cgrunenberg, I appreciate your assistance…

I’m experiencing an issue using the File Items.scpt as provided.

I’ve changed the property pGlobalSearch to true and I’m working with a file named Credit Card Statement@Credit Cards. The script moves the file into the Credit Cards group; however, @Credit Cards is not removed from the record name.

I’m far from being proficient with AppleScript, but it appears the intent is to remove that portion of the name. Am I correct? If not, can someone suggest language that could be added to do so?


Only after changing pRename to true.

Thank you…should have noticed it.

After changing pRename to true, the name is still not changed and the following error message appearrs:

Can’t set «class DTcn» id 108203 of «class DTkb» id 1 to “Credit Card Statement”.

Could you please post your current version of the script? I just tried this and it works as expected. In addition, which version of macOS do you use?

I’m using macOS 11.2.1, DEVONthink 3.6.2, on a 2018 MacBook Pro.

-- © pete31 Dec 02, 2020
-- Simplified & enhanced by Christian Grunenberg

property pGlobalSearch : true -- Set to true to search in all opened databases. Otherwise the current database of the records will be used.
property pRename : true -- Set to true to rename items after filing

on performSmartRule(theRecords)
	tell application id "DNtp"
			repeat with thisRecord in theRecords
				set thisName to name without extension of thisRecord
				if thisName contains "@" then
					set theOffset to (offset of "@" in thisName)
					set theGroupName to (characters (theOffset + 1) thru -1 in thisName) as string
					set theQuery to "name==" & theGroupName & space & "kind:group kind:!tag"
					if (pGlobalSearch) then
						set theResults to search theQuery
						set theResults to search theQuery in root of database of thisRecord
					end if
					set didMove to true
					set numResults to count of theResults
					if numResults is 1 then
						set theGroup to item 1 of theResults
						move record thisRecord to theGroup
					else if numResults is 0 then
						set theGroup to create record with {name:theGroupName, type:group} in incoming group of database of thisRecord
						move record thisRecord to theGroup
						log message info "Ambiguous destination." record thisRecord
						set didMove to false
					end if
					if didMove and pRename then set name of thisRecord to (characters 1 thru (theOffset - 1) in thisName) as string
				end if
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
end performSmartRule

Did you edit the external script ~/Library/Application Scripts/com.devon-technologies.think3/Smart Rules/File Items.scpt? It’s not recommended to modify the default scripts, it’s better to use a copy so that future updates won’t revert your changes. Or to use an embedded script in the rule.

Anyway, does restarting the app fix this? Your script works also fine.

I did edit the external script when the embedded copy did not function properly. I have since revised those edits back to their original.

I have restarted DT 3 and rebooted my MacBook Pro.

I was able to get the smart rule to work properly if I dropped the file into the Inbox belonging to the same database (Financial) as the target group (Credit Cards). I had been dropping the file into Global Inbox expecting the script to move it to the target group and remove the @ and everything after it…that did not work properly for me.

Does a file dropped in the Global Inbox move to the correct database and group for you?

Instead of modifying the script, it may be possible to use a Move action to move the file to its destination database first.

This is working for me when adding files to the Global Inbox…

Perfect!! Just what I needed. Thank you very much.

By the way, what is the procedure for adding a graphic to a post? It’s not obvious to me…copying and pasting doesn’t seem to work.

You’re welcome :slight_smile:

Drag and drop or copy and paste should work.

In iOS you can press this button to add a photo from the camera or photo library…

Thanks again, Jim. I’ll give it another try…