Dear forum member, just need help for one line of coding (I believe). Perhaps also a reminder of caution when using the stock script “Move___Cmd-Ctrl-M.scpt”.
I am trying to modify the stock scripts “Move___Cmd-Ctrl-M.scpt” because the code used in this script will remove all instances of the selected files from all groups (replicants) and move just one single instance to the destination group. Reference to some other posts (thanks),
I basically just add two lines of modified code:
(1) “set theFrom to the first parent of thisItem”
(2) “set thisItem to move record thisItem from theFrom to theDestination”
However, this still doesn’t work as expected. It is because “first parent” is referring to the group that “first-created” the file’s instance, not the group where the current replicant is located (which could be the nth instances). I tried using just “parent” but I guess the syntax is incorrect because all instances of the files in other groups are still removed but one in the destination group.
Thank you in advance
George
(*
Move the selected record(s) to a destination
that was selectected from the Group Selector panel
20140112.1
*)
try
tell application id "DNtp"
set theDatabase to current database
-- set theSelection to selection
set theSelection to (the selection as list)
if theSelection is {} then error "Please select something"
set fromPath to (the location of item 1 of theSelection) & (the name of item 1 of theSelection)
set fromDatabase to the name of theDatabase
set theDestination to (display group selector "Select a Destination")
if theDestination is {} then error "We had a problem choosing the destination"
set toPath to (the location of theDestination) & (the name of theDestination)
set toDatabase to the name of the database of theDestination
repeat with thisItem in theSelection
set theFrom to the first parent of thisItem
-- just code for seeing the name of first parent, not used in actual code
-- set theParentName to the name of theFrom as string
-- display alert theParentName
-- run this line to move just the replicant within this group to the selected group
set thisItem to move record thisItem from theFrom to theDestination
-- run this line to move all instances of the records to the selected group
-- move record thisItem to theDestination
end repeat
-- 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"
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