# 'move' method removes replicants of target item

**URL:** https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251
**Category:** Automation
**Created:** [July 7, 2016, 8:29pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251 "2016-07-07T20:29:56Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![mishana](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mishana/32/6897_2.png) [@mishana](https://discourse.devontechnologies.com/u/mishana)
#### Post date: [July 7, 2016, 8:29pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/1 "2016-07-07T20:29:56Z")

</div>

Hello,

I uses move method for moving some record to another folder. It works fine. But when I have some replicants of target item, ‘move’ method sucessfully move my record and remove all of it’s replicants. I want to move some record by script and preserve it’s replicants.

Is there any solution for this problem?

Thank you.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [July 7, 2016, 8:38pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/2 "2016-07-07T20:38:13Z")

</div>

If you are moving records between databases, replicants will not be preserved.  
Replicants are instances of the same file in the same database. Cross-database replicants are not possible.

---

<div class="post-metadata">

### Author: ![korm](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/k/e0b2c6/32.png) [@korm](https://discourse.devontechnologies.com/u/korm)
#### Post date: [July 8, 2016, 12:33am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/3 "2016-07-08T00:33:34Z")

</div>

I recall there was a reason for this, but I don’t recall the reason.

If I have a set of groups "a’, “b”, “c”. Make a text record in “a”. Replicate it to “b” and “c”. Then select the record in “a” and run this script:

```auto

tell application id "DNtp"
	set theRecord to the content record
	set theLocation to create location "Target"
	set theResult to move record theRecord to theLocation
end tell

```

The record from “a” is moved to “Target” and the replicants in “b” and “c” disappear.

I’d suggest you try this yourself Jim and let us know how that goes.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [July 8, 2016, 1:11am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/4 "2016-07-08T01:11:55Z")

</div>

Indeed.  
It does happen when walking the selection too.  
It doesn’t happen with a manual drag and drop to the Target folder.

---

<div class="post-metadata">

### Author: ![mishana](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mishana/32/6897_2.png) [@mishana](https://discourse.devontechnologies.com/u/mishana)
#### Post date: [July 8, 2016, 1:18am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/5 "2016-07-08T01:18:36Z")

</div>

> [@](#):
>
> The record from “a” is moved to “Target” and the replicants in “b” and “c” disappear.

korm,

I executed your script, then exactly it happen. ‘a’ is moved to ‘Target’ directory and “b” and “c” disapper.

BLUEFROG,

Sadly it happen even between same database. Using drag and drop for moving works as expected, but ‘move’ method doesn’t.

---

<div class="post-metadata">

### Author: ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)
#### Post date: [July 8, 2016, 2:29am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/6 "2016-07-08T02:29:30Z")

</div>

@mishana: Yep. I also confirmed it. I will let Development know it is (at least) unexpected behavior.

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 8, 2016, 7:17am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/7 "2016-07-08T07:17:29Z")

</div>

You have to specify the “from” parameter if you want to move only the replicant located in a certain group.

---

<div class="post-metadata">

### Author: ![korm](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/k/e0b2c6/32.png) [@korm](https://discourse.devontechnologies.com/u/korm)
#### Post date: [July 8, 2016, 10:01am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/8 "2016-07-08T10:01:43Z")

</div>

> [@cgrunenberg](#):
>
> You have to specify the “from” parameter if you want to move only the replicant located in a certain group.

Alright. This works:

```auto
tell application id "DNtp"
	set theRecord to the content record
	set theFrom to create location "a"
	set theTo to create location "d"
	set theResult to move record theRecord from theFrom to theTo
end tell

```

There is probably a cleaner way to define the “from” and “to” locations though.

The dictionary has

> [@](#):
>
> move (verb)Move all instances of a record or one instance from the specified group to a different group.

So, that takes a bit of thought. Maybe

```auto

Move all instances of a record to a different group. Specify the "from" group to to move a single instance to a different group.

```

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 8, 2016, 12:27pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/9 "2016-07-08T12:27:08Z")

</div>

Thanks, changed.

---

<div class="post-metadata">

### Author: ![korm](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/k/e0b2c6/32.png) [@korm](https://discourse.devontechnologies.com/u/korm)
#### Post date: [July 8, 2016, 12:34pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/10 "2016-07-08T12:34:42Z")

</div>

> [@cgrunenberg](#):
>
> Thanks, changed.

Thank you!

Is there a better way to specify “from” and “to” than what I did in my last snippet above?

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 8, 2016, 12:47pm UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/11 "2016-07-08T12:47:00Z")

</div>

Depends on the actual task, e.g. recursive functions usually know the parent group. Sometimes the parents relationship (e.g. parent 1 of theRecord) might be useful too.

---

<div class="post-metadata">

### Author: ![mishana](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mishana/32/6897_2.png) [@mishana](https://discourse.devontechnologies.com/u/mishana)
#### Post date: [July 9, 2016, 2:41am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/12 "2016-07-09T02:41:59Z")

</div>

Thank korm, cgrunenberg! It works as expected.

---

<div class="post-metadata">

### Author: ![korm](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/k/e0b2c6/32.png) [@korm](https://discourse.devontechnologies.com/u/korm)
#### Post date: [July 9, 2016, 11:05am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/13 "2016-07-09T11:05:03Z")

</div>

> [@cgrunenberg](#):
>
> Depends on the actual task, e.g. recursive functions usually know the parent group. Sometimes the parents relationship (e.g. parent 1 of theRecord) might be useful too.

OK

Here’s a cleaner version that moves the record from its parent group, to a group selected at the time the script is run. This version also works to move groups (and their replicants, if any). The moves are limited to the current database, although instructions in the script code explain how to remove this limitation.

```auto

(* Script to move a record from one group to another while
preserving any existing replicants of the reccord

korm v1 20160709
*)

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

tell application id "DNtp"
	try
		set theRecord to the (first item of (the selection as list))
		set theFrom to the first parent of theRecord
		-- to move between databases,
		-- remove the following line and replace with "set theTo to display group selector"
		set theTo to display group selector for the current database
		set theResult to move record theRecord from theFrom to theTo
		
	on error
		display alert "We've had a problem. Check your selection and try again."
	end try
	
end tell

```

---

<div class="post-metadata">

### Author: ![ipanini](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/ipanini/32/87_2.png) [@ipanini](https://discourse.devontechnologies.com/u/ipanini)
#### Post date: [July 23, 2016, 9:47am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/14 "2016-07-23T09:47:55Z")

</div>

> [@korm](#):
>
> > [@cgrunenberg](#):
> >
> > You have to specify the “from” parameter if you want to move only the replicant located in a certain group.
> 
> Alright. This works:
> 
> ```auto
> tell application id "DNtp"
> set theRecord to the content record
> set theFrom to create location "a"
> set theTo to create location "d"
> set theResult to move record theRecord from theFrom to theTo
> end tell
> 
> ```
> 
> There is probably a cleaner way to define the “from” and “to” locations though.
> 
> The dictionary has
> 
> > [@](#):
> >
> > move (verb)Move all instances of a record or one instance from the specified group to a different group.
> 
> So, that takes a bit of thought. Maybe
> 
> ```auto
> 
> Move all instances of a record to a different group. Specify the "from" group to to move a single instance to a different group.
> 
> ```

May I ask about “The dictionary” here?

- what dictionary is this? Is it an “application” dictionary?  
I ask because interested in scripting, but most of all interested in ‘how to best gather information and snippets’ of scripting.  
Adding it to an application dictionary seems interesting.

---

<div class="post-metadata">

### Author: ![korm](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/k/e0b2c6/32.png) [@korm](https://discourse.devontechnologies.com/u/korm)
#### Post date: [July 23, 2016, 10:55am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/15 "2016-07-23T10:55:05Z")

</div>

Every scriptable application in macOS has a “dictionary” that is accessed by Script Editor (an app provided by Apple) or whatever other application is being used to write and compile that script. I use Script Debugger, Script Editor is freely available for all macOS users (in older versions of the OS it was called AppleScript Editor), the Xcode development environment also uses the dictionary, and so on. The dictionary for any scriptable application is written and maintained by the developer of that application. It is a text file (usually with an .sdef extension) that resides inside the application package along with other resources that the application uses. It doesn’t matter where the dictionary lives, because Script Editor, etc., knows about it and will give you access to it.

Run Script Editor. Choose File \> Open Dictionary. A list of scriptable applications is presented to you. Scroll down to DEVONthink Pro Office.app or whatever other app you’re interest in, select the app, and press Choose. The dictionary opens. It contains information about the scriptable commands, classes and properties, enumerations, and data types that that app supports in scripts. For example, the DEVONthink Pro Office dictionary entry for the “move” command (i.e., a verb) is shown below. (This is the updated version mentioned above for v2.9.) Not to go into it here, but there are lots of resources available for learning AppleScript – Frederiko recently posted some links here, I believe, if you look for their posting on the topic of scripting.

The dictionary is an aid – it doesn’t do anything other than explain how to do things in your script for that application.

 ![](http://i.imgur.com/IDRXS5U.png)

---

<div class="post-metadata">

### Author: ![system](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/4/4e6ff70c96be2eb307a274d890bba8d71ba671b3.png) [@system](https://discourse.devontechnologies.com/u/system)
#### Post date: [January 21, 2022, 11:44am UTC](https://discourse.devontechnologies.com/t/move-method-removes-replicants-of-target-item/20251/16 "2022-01-21T11:44:44Z")

</div>


