how do you use comments?

True enough, it’s a bit of a kludge; but with a bit of prioritizing in the comments field, better than nothing.

AMEN :astonished:

Thanks, Bill

That would be truly wonderful!

Rick

I only came across this thread today, but it looks like the 2 scripts from Eiron are going to revolutionize my use of DT (I’ve decided to steer clear of the “delete existing comments” option). Thanks, Eiron! To make even more finely grained groups, I’d like to set up a smart group that contains only files with 2 specific tags in the comments. Since the name of the group seems to define the term to be searched, it doesn’t seem to be a “simple” matter of tweaking the AppleScript. DOes anyone know how this might be accomplished?

This just caught my eye. Actually it is rather trivial to do this in Automator now. The “Add Items to Currrent Group” action will put the comments of a file into the Comments of a record. Also: If a Finder comment of an item contains the string “original: ”, where the furl is an (file) url to the original file, it will be set as the value for the URL field in the new database record. This would allow you to go to the original source easily.

One of our customers who visited our booth at the MacWorld in SF asked me the same question and I created it on the spot for him. Since it’s so easy I’ll leave it as an exercise to the reader (I hated these sentences in my university advanced math books, but here I really feel it is well deserved). :wink:

Rickl,

If I understand you right, you want a script that will seek to match 2 or more specific words in the folder title. The “All words in comments” script does just that (i.e. it requires that every word in the title of the smart folder be matched in the comments field). The “Any words in Comments” script, on the other hand, will gather a replicant if just one of the words in the folder’s title matches.

In case you dont have the script, here it is:


-- Smart Group (All Words)
-- Created by Christian Grunenberg on Oct Fri 22 2004.
-- Copyright (c) 2004-2005. All rights reserved.

on run
	try
		tell application "DEVONthink Pro"
			repeat
				display dialog "Enter the words to use:" default answer "" buttons {"Cancel", "OK"} default button 2
				set theWords to the text returned of the result
				if theWords is not "" then exit repeat
			end repeat
			set theRecord to create record with {name:theWords, type:group, attached script:"~/Library/Application Support/DEVONthink Pro/Smart Group/All Words In Comments.scpt"}
			my triggered(theRecord)
		end tell
	on error error_message number error_number
		if the error_number is not -128 then
			display dialog error_message buttons {"OK"} default button 1
		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 comments operator all words 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
			display dialog error_message buttons {"OK"} default button 1
		end if
	end try

Again, this is a tweaked version of one of Christian’s scripts and quite easy to figure out if you look closely. The line


search theString comparison no case within comments operator all words replicate to theRecord with removing replicants

is most likely the one you’ll want to play with in future.

Cheers,

Eiron

The second line above creates a replicant.

Is it possible to move the record into a group rather than replicate it?

Thanks for the explanation, Eiron. As you point out, it is possible to work out after the fact if we look closely.

Is there any way to have a smart folder in which it collects files that have ONLY one specified term (or more)?

For example, let’s say I have a hierarchy as follows:

  • Education
    – EducationalTheory
    – Pedagogy
    – LanguageAcquisition

And I have some files tagged “education”, others tagged “EducationalTheory,Education”, etc., and I want for the top level to be a smart folder that collects files that have ONLY “education” in the comments field; thus, if a file has the tags “Education,EducationalTheory”, it would go into the smart folder EducationalTheory which is using the “Any Words” script. On the other hands, files which have only “education” in the comments field would go into the top group.

Any help with this?

Talazem,

I haven’t tried this, but as far as I know, a search for “any word” shouldn’t find EducationalTheory, that would require a phrase search, but I may be wrong.

The bigger issue here is that it’s not recommended that you store documents at different levels of a hierarchy - it just confuses the DT AI. The best practice would be for your Education folder to contain only subfolders, one of which could be EducationGeneral, say. Bill has written at length about this on the forum.

If you MUST file at different levels and your search still doesn’t work properly, the easiest way to fix your problem might be to rename the subfolder something like EduTheory and use that as a keyword.

For anyone else who has questions re Smart Folders and Comments, here’s the search syntax:


search [Unicode text] : The search string.
[comparison exact/fuzzy/no case] : The comparison to use (default exact).
[in record] : The group to search in.
[label integer] : Index of label(0-7) of records.
[locking boolean] : The locking of the records.
[operator all words/any word/phrase/wildcards] : The operator to use (default all words).
[removing replicants boolean] : Remove existing replicants in destination group (on by default).
[replicate to record] : An optional destination group or sheet filled with replicated search results.
[state boolean] : The state of the records.
[within all/comments/contents/paths/titles/URLs] : The attribute(s) to search within (default all).

Cheers,

Eiron

Well, I’m new to DT… just got the Professional demo yesterday.

One useful thing I found for comments is for bank statements. I don’t want to OCR or do PDF+Text on my bank statements, but do want to know what check numbers are scanned in with a statement.

I do a multi-page PDF with a scan of the check, then within BT in the comment field I put “check number ###”. If I have multiple checks I just do “check number 123, 555, 983” etc…

I just type in ‘check number ###’ in the search box and it pulls the statement right up… very nice. :slight_smile:

Hmm. I have entered a bunch of comments, but am not able to find any of them with Spotlight. mdimport is consuming 0.00% of CPU cycles, so I assume Spotlight’s index is up to date. Do I have to set a flag somewhere to have them searchable from Spotlight to DTP?

DEVONthink databases aren’t Spotlight-searchable (yet).

It would be wonderful if everytime you drop a file/import/or save a file you are asked if you want to add tag to the comments.

Any chance to tell the script/DT to do that?

Thanks Thomas

When Spotlight comments made their appearance I annotated thousands of files in the Finder with “comments” as I understood them, i.e. sentences or phrases. This has caused problems as third-party software has appeared to enhance Spotlight. A Dashboard widget called TagBag goes through all my comments and extracts the “tags” or “keywords” to help me find files, but of course right at the top are words like “3”, “a”, and “an”, which bloat the list and make it much less useful.

I’m not sure exactly what the lesson is here, but I think possibly it supports Bill’s call for multiple metadata fields. Specifically, I think a “comment” is something to be read by a human, while if a field is designed to hold metadata to be searched by a computer it should be called “keywords” or “tags” or whatever, and people should be forced or guided to input data in a suitable format, e.g. comma-separated.

Just a thought…

DEVONthink (and Spotlight) comments are too unstructured for me to consider using them specifically for keyword/tag metadata.

WebnoteHappy’s tag implementation is surprisingly effective for its simplicity, making me wish for something similar in DEVONthink.

Thomas:

  1. Create a folder somewhere on your hard drive. Call it “import to DT.”

  2. Open Automator

  3. Drag the following actions, in this order, from the list on the left, into the pane on the right side of the Automator window:

“Add Spotlight Comments to Finder Items”
“Set Current Group”
“Add Items to Current Group”
In this last action, choose “import” from the pop-up

  1. “Save as Plug In…”
    4.a. choose “Folder Action” from the pop-up
    4.b. chose your newly created folder (“Import to DT”) from the next pop-up.
    4.c. Save
  2. Drag a file into the “Import to DT” folder.

This should work.

Fred, it works somehow - the ability to choose the folder would be fine.

But what I was looking for is an automatic pop up for comments in DT. Your way urges me to insert tags in spotlight comments before importing it. Or did I miss something?

Update: I did modify your Automator script a little and it works now. I made the action visible and told it to ask for the folder

Thanks again!

One final question: how can I remove the files I draf into that folder autmatically after importing them to DT?

Hi all,

I’m using those smart group script for a couple of weeks and must say the improved the benefits of DT enormously.

There is just one issue: it would be necessary to restrict the search for the item to certain folders otherwise - after some time - I get smart groups with mixed results or I need to use extra keywords to avoid that.

I cannot script any idea how to tell the script in which group/s to search?

Thanks Thomas