I’d like to write a script that deletes all the replicants of a file, but leaves the database item in its current location.
I assume that deleting a replicant is accomplished by deleting a parent item?
Further, it seems that the location of the database item is always returned as item 1 of the parents list. Is this guaranteed, which would greatly simplify scripting, or do I need to iterate through the parent list and find the one that matches the item’s location?
The only difference between a replicant and other items is that a replicant has multiple parents. Therefore all you have to do is to remove the replicants from all parents except the first one.
--Checks if record is already replicated to specific group
--expects: record and group as objects; returns boolean
on RecordHasReplicaInGroup(myRecord, myGroup)
log ">>>> RecordHasReplicaInGroup"
set hasReplicaHere to false
tell application "DEVONthink Pro"
-- Is DT record at top level?
if exists parent 1 of myRecord then
-- loop through parents of DT record
set parents_count to (count parents of myRecord)
repeat with i from 1 to parents_count
set parent_group to item i of (parents of myRecord)
if myGroup is parent_group then set hasReplicaHere to true
end repeat
end if
end tell
log ">> RecordHasReplicaInGroup returns: " & hasReplicaHere
return hasReplicaHere
end RecordHasReplicaInGroup
I’m still too AppleScript-unsavvy to understand exactly what it does, though it inspired me to wonder how upcoming replicant-based tags and UI related changes might influence replicant management in general and possibly “solve” some of the existing issues as a side effect.