Is there a way to create a new group in DT when moving a document from the inbox, so that the document will move into the new group?
In finder, I use the “New Folder” item all the time to create a new folder to place a document in. In DT, I have to review the document, look for a group, and if there’s not already a group to move it to, then I have to create a new group in the right location, then go back and move the document into the group. Is this the only way to do it?
I don’t want to just throw everything together in one group and depend on search to retreive it later. I like using hierachical groups and want to file documents in a way that would easily transfer out of DT and into finder if I desire later.
You can select the new document in the Inbox and right click > Group Items. This creates a new group in the Inbox with the selected items — with one item the group has the same name, with more than one, you’ll have to name it explicitly.
Then you can move the new group into the preferred location in the normal way.
Yes, an AppleScript with display group selector can do that.
A simple version could look like this:
-- Move records
tell application id "DNtp"
try
set theRecords to selected records
if theRecords = {} then error "Please select some records"
set theGroup to display group selector "Move to:"
repeat with thisRecord in theRecords
move record thisRecord to theGroup
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
But such a simple version doesn’t consider some (edge) cases. We would e.g. lose replicants if we were using the simple version with a selection while DEVONthink shows search results.
Here’s (almost) the version I use. This script additionally checks some other things but you probably won‘t notice that. With that version all potentially harmful cases are covered, I think.
-- Move records
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
property openGroup : false
tell application id "DNtp"
try
set theRecords to selected records
if theRecords = {} then error "Please select some records"
set theRecords_NonIndexedNonReplicants to selected records whose indexed = false and number of replicants = 0
if theRecords_NonIndexedNonReplicants ≠ {} then
set theRecords_CantMove to selected records whose (indexed = true) or (indexed = false and number of replicants > 0)
set theGroup to display group selector "Move to:"
if my checkLockedGroup(theGroup) = false then
display alert "Canceled" buttons {"Ok"} default button 2 message "Moving canceled: Group is locked folder" as critical
return
end if
show progress indicator "Moving... " steps (count theRecords) as string with cancel button
repeat with thisRecord in theRecords_NonIndexedNonReplicants
step progress indicator (name of thisRecord as string)
move record thisRecord to theGroup
end repeat
if openGroup then
open window for record theGroup with force
activate
end if
if theRecords_CantMove ≠ {} then
set theRecords_CantMove_Count to (count theRecords_CantMove)
if theRecords_CantMove_Count = 1 then
set theText to " Record is indexed or replicated"
else
set theText to " Records are indexed or replicated"
end if
my showRemaining(theRecords_CantMove, ("Moving: " & (theRecords_CantMove_Count as string) & theText))
end if
else
display alert "Canceled" buttons {"Ok"} default button 2 message "Moving canceled: All records are indexed or replicated" as critical
return
end if
hide progress indicator
on error error_message number error_number
hide progress indicator
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
on checkLockedGroup(theGroup)
try
tell application id "DNtp"
try
if indexed of theGroup = true then
set thePath to path of theGroup
else
set thePath to missing value
end if
end try
end tell
if thePath ≠ missing value then
set theDirectory_Attributes to (current application's NSFileManager's defaultManager's attributesOfItemAtPath:(thePath) |error|:(missing value))
if ((theDirectory_Attributes's objectForKey:(current application's NSFileImmutable)) as boolean) = true then
set isNotLocked to false
else
set isNotLocked to true
end if
else
set isNotLocked to true
end if
return isNotLocked
on error error_message number error_number
activate
display alert "Error: Handler \"checkLockedGroup\"" message error_message as warning
error number -128
end try
end checkLockedGroup
on showRemaining(theRecords, theMessage)
tell application id "DNtp"
try
set search results of (open window for record (root of inbox) with force) to theRecords
activate
display alert "These records couldn't be moved" buttons {"Ok"} default button 2 message theMessage as informational
on error error_message number error_number
activate
display alert "Error: Handler \"showRemainingRecords\"" message error_message as warning
error number -128
end try
end tell
end showRemaining
I use an applescript to assist with processing Inbox items
This includes title, tags, … and moving out of the Inbox
The script could also include creating a group
Just curious as to the use case for this
Most of my notes are stored as single entries in the Filing Cabinet group