Move items with the keyboard between databases (re-imagined)

Correct and that’s definitely the expected behavior.

I think @jprint714 was referring to a new hierarchy being created instead of going into an existing one.

…and therefore I wonder whether it’s a matter of the case (sometimes uppercase is used but not always in his examples).

Can you clarify what you’re referring to?
Is it a matter of new groups with names having a different case or wanting to file into an existing group structure and the smart rule is creating a new structure altogether?


E.g. Articles vs. ARTICLES, -RAW vs. - Raw, Gorillas vs. GORILLAS etc.

The smart rule creating new groups as the case of the input of the File action does not match the case of the existing group names. It’s case sensitive.

In this hierarchy, including the Path bar, what would be the Top Group Name


I though it would be Articles or Inbox, but it appears to be the database name 6.

Unified inboxes? Then this is currently correct (but not sure how that’s related to the above issue).

It still uses the database name, even if the Inboxes aren’t unified.

And I was looking at a way to create a unified smart rule that would use the group name as the main group to file into and the top group name as the subgroup.

Should be possible if it’s not inside the local inbox.

So this works, but it obvious requires uniformity in group naming and the groups are at the root of the source database…

After dropping a file into an article and a document group for Gorillas…

@jprint714 : Take special note of the uniform group names in the source and destination database’s group structures.
You could create a smart rule for Articles and one for Documents to relax this requirement a little but this is showing a possible solution as well as why it’s best to be uniform as much as possible.

1 Like

Thank you ever so much for this @BLUEFROG ! I’m very grateful… And I’m sorry to take so long getting back to you – I was just in transit when you put this up. I’m going to set this up right now, and might have quick questions or two for you along the way…

Here are some quick ones: Will this smart rule work for groups in my Global Inbox that already have existing files? If not, how can I trigger the smart rule so that it moves those files?

Also, like I said, I’ve got about 20 groups in my Global Inbox. Is it possible to use one smart rule – with the configurations you’ve created here – for all 20 groups? Or do I need to create 20 smart rule for each group?

Thanks so much again… I’m setting this up right now. Thanks!

You’re welcome.

It’s not going to work completely out of the box unless you have conforming group names as I’ve indicated above.
The smart rule I posted is based on a very uniform naming convention, i.e., the groups receiving data are named the same as the destination groups.
If you’re varying from this, then yes, extra smart rules will likely need to be employed.

Also, bear in mind I am presenting a smart rule requiring no Execute Script actions. Obviously the options are more powerful when using one but not everyone is inclined to scripting and smart rules should be accessible to everyone.

1 Like

I think I follow what you’re saying here re: uniformity of groups. So, in this example I would need to have Global Inbox>Articles>GORILLAS and then Active Projects [database] >GORILLAS>3. Articles>- Raw (I use a hyphen and a space before “Raw” – and I used it uniformly).

In other words, this smart rule won’t work if one group is named GORILLAS and the other is Gorillas – or if on the receiving end there RAW / -Raw / - raw , correct? Everything has to be uniform or it won’t work. Have I got that right?

BTW, just so I can better understand how these things work, would Group Name refer to “3. Articles” and does Top Group Name refer to “GORILLAS” (under the Active Projects database)?

Thanks again!

You’d need both the case-sensitive Gorillas and the full group name, e.g., 3. Articles in both places.

In the receiving groups, the Top Group Name is 3. Articles, 4. Documents, etc.
The Group Name is the animal name here.

Aha! I’m so glad I asked as I feared that I was overlooking a key element! I think I’ve got it sorted out now. I’ll circle back w/ an update. Thanks so much, @BLUEFROG !

You’re welcome.

1 Like

Hi, I’ve been setting this up, and am just wondering how I can test this with “on demand” smart rule trigger – so that I test the smart rule itself, without disrupting the “On Import” action. Thanks!

Sorry - I’m just refining these smart rules and the process, and I had just a few more quick questions…

…Under Change Aliases to > I’ve left that blank (just as you did in the screenshot). But when I click OK, and then double click on the smart rule again, it autofills with the “Aliases” Placeholder;

Is this Ok? Should I be doing something else?

Like I said, I’m still refining these smart rules and the process so that there’s the perfect kind of parity you advised me to have to ensure that everything works. As I understand it, the existing rules will automatically file newly imported files instantly – and that’s great!

Is there a way to trigger the smart rules for filing the files that are already in these folders?

Thanks so much!

And…I’ve tried selecting Tools > Perform Rules [and] Apply Rules > [applied the appropriate rules that @BLUEFROG set up] for the Global Inbox, “I. ARTICLES”, the discrete groups underneath them – as well as selecting the individual files in the groups and applying Perform Rules and Apply Rules.

I’ve also tried selecting Perform the following actions: > [changing from On Import to On Demand] → and then trying applying Perform Rules and Apply Rules.

So far, none of this has moved any files. Really not sure what I’m doing wrong, or how else to move files that are already in my Inbox groups to my Database groups.

Any ideas / suggestions?

Thanks again!

Hello @korm
thanks very much for your script. I am trying to create a variant using keyboard maestro whereas I would create a menu palette with my most common destinations instead of going through the search box.
I tried to create a template script (which I can later adapt to multiple destinations)
The objective is move selected item located in the Global Inbox Database to Temp1 Group in Global Inbox Database (I use global inbox as my main database)

Below is the modified script and above it an illustration of my modification

Basically all I did was

  • delete references to search box
  • add the definition of the destination group set theDestination to “Temp1” (I also tried theDestination to Temp1).

The script does not run: error on definition of destination.

Obviously I must have set the destination variable incorrectly.

Sorry to bother you and once again, thanks very much for a very nice script.

Original script by Korm
Move the selected record(s) to a destination
that was selectected from the Group Selector panel
20170207.3 added optional guard against moving to a database's root
Modified by Ngan 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

-- Specify the full screen resolution of the active monitor
-- set {screenWidth, screenHeight} to {4608, 1944}
-- set {screenWidth, screenHeight} to {3360, 1890} 
set {screenWidth, screenHeight} to {3840, 2160}
set {WinWidth, WinHeight} to {screenWidth / 2, screenHeight * 0.5} -- newly opened main window sized as a quarter of the screen
set yAxis to 0
set xAxis to 0

-- Option Settings 1
set MovAllInstances to false -- Set to true if wanting to consolidating all replicants into one
property NoTop : false -- set to true (no quotes) to guard against moving to root

	tell application id "DNtp"
		set theDatabase to current database
		set theSelection to selection
		set theDestination to "Temp1"
		if theSelection is {} then error "Please select something"
		set theFrom to the current group
		set fromPath to (the location of item 1 of theSelection) & (the name of item 1 of theSelection)
		set fromDatabase to the name of theDatabase		
		if theDestination is {} then error "We had a problem choosing the destination"
		if the location of theDestination is "/" then -- new conditional added in 20170207.3
			if NoTop then error "Cannot move to the database root"
		end if
		set toPath to the location of theDestination
		set toDatabase to the name of the database of theDestination
		if MovAllInstances is true then
			repeat with thisItem in theSelection
				move record thisItem to theDestination
			end repeat
			repeat with thisItem in theSelection
				set thisItem to move record thisItem from theFrom to theDestination
			end repeat
		end if
		-- Post the result to the Log
		set movedFrom to "Moved from: " & fromPath & " in " & fromDatabase
		set movedTo to " -- Moved to: " & toPath & " in " & toDatabase
		set theLogEvent to log message (movedFrom & movedTo) info "Mover Script"
		open window for record (item 1 of theDestination)
		-- Option settings 2: location of the newly opened destination window
		set bounds of window 1 to {xAxis, yAxis, xAxis + WinWidth, yAxis + WinHeight} -- upper left corner
		-- set bounds of window 1 to {xAxis, yAxis + WinHeight / 2, xAxis + WinWidth, yAxis + WinHeight / 2 + WinHeight} -- mid of left edge of the screen
		-- set bounds of window 1 to {xAxis, yAxis + WinHeight, xAxis + WinWidth, yAxis + 2 * WinHeight} - lower left corner
	end tell
on error error_message number error_number
	if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try