How can I create a smart group that gathers only an exact phrase?
I can harvest all words in the supplied Smart Group script (which ends up as an AND/OR search), but I want to restrict the group to an exact 2 or more word phrase. I tried using quotation marks around around the phrase (like in Google) but that doesn’t work.
ie. I want “Word1 Word2” (or another way, Word1 immediatley adjacent WORD2). I dont want all occurances of Word1 AND/OR Word2.
Andrew, you can’t yet do that, although a future version of DT Pro will include more versatile smart group features.
Workaround: Instead, try this.
[1] Do a Phrase search. (But you will have to wait for quotation marks, NEAR and other more sophisticated query operators until DT Pro version 2.0 is released.)
[2] Select the search results and replicate them to a new group you’ve created for this purpose.
Advantages: If necessary, you can do multiple searches to handle various ways in which your search terms might appear, e.g., Aldous Huxley in one search, Huxley, Aldous in another search, replicating both sets of results to your holding group.
Disadvantage: When you add new content, you will have to repeat the operation in order to pick up any relevant new items. (Delete the existing search results group, or empty the contents and repeat the search(es).)
Note: Take a look at the existing Smart Group scripts in ~/Library/Application Support/DEVONthink Pro/Smart Group/. There are several variants including ALL Words, ANY Word, and check and label options.
Just save this script in ~/Library/Application Support/DEVONthink Pro/Smart Group (the only difference to the “All Words” script is that the operator has been changed to “phrase”):
-- Smart Group (Phrase)
-- Created by Christian Grunenberg on May Mon 22 2006.
-- Copyright (c) 2006. All rights reserved.
on run
try
set scriptPath to POSIX path of (path to me)
if scriptPath ends with "/" then set scriptPath to ""
tell application "DEVONthink Pro"
repeat
display dialog "Enter the phrase to use:" default answer "" buttons {"Cancel", "OK"} default button 2
set thePhrase to the text returned of the result
if thePhrase is not "" then exit repeat
end repeat
set theRecord to create record with {name:thePhrase, type:group, attached script:scriptPath}
my triggered(theRecord)
end tell
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
end run
on triggered(theRecord)
try
tell application "DEVONthink Pro"
if type of theRecord is group then
set theString to (name of theRecord) as string
search theString comparison no case within all operator phrase replicate to theRecord with removing replicants
end if
end tell
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
end triggered
Wow, that easy!
Thanks That saves me a whole lot of manual classifying and replicating (and worrying that some items slip through the net). I have lots of stuff that can easily sit across multiple categories. Now I can create topic ‘themes’ whenever I see fit, regardless of the original articles location.