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.
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.
(* 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"
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
display alert "We've had a problem. Check your selection and try again."
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.
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.