Greg: With DT I always have the feeling, that there might be a hidden knob, that does exactly what I intended to do. This is also why I often hesitate to ask the forum: I might just look stupid. Like now. Thanks a lot for the tip.
cgrunenbeg: Well… thanks for the code in the first place. However, until now I could never get into the habbit of using scripts exhaustively, although I know, in principle, they are awfully powerful.
I think, my gripes are firstly the sheer number of entries in the scripts-menu, and secondly, the buggyness (sp?) of a lot of scripts. Scripts seem to be especially bad at exception handling, if e.g. a path is set wrong, it won’t ask to seek the right path, but instead quit without doing anything. Also, they tend to be very slow.
The reason I am bashing them is mainly to beg, if you could implement versioning into DT2 in a more user-friendly and elegant way
Most scripts shipped with DT Pro should present useful error messages (v1.1 will improve some scripts in that area). And scripting DT Pro is (compared to other scriptable applications) actually very fast (for example the speed of importing mails is limited by the mail client, not by DT Pro).
But don’t run scripts via Apple’s Script Editor - that’s always painfully slow (around 10 times slower than running them via the Scripts menu).
I would not hesitate to ask questions in the forum-that’s what it’s for!
I also forgot to mention that you can toggle the lock/unlock status with the padlock icon that appears at the top of the viewer pane. I find the contextual menu easier to use, however some prefer the icon.
Thanks for the heads-up on EverNote. It kills me at work to not have DT on my computer. For what it’s worth, I also would love a versioning system in DTP. I’m always hesitant to ask for more features because I would hate to see DT become bloated like anyother program made to please everyone (MS Word). Thanks again.
Versioning would be a great feature to add to DT. As stated by others; a simple, elegant versioning process would be appreciated.
Very few knowledge management programs handle versioning well. Most of the time, versioning involves complicated check-in/check-out schemes (for network based systems, of which, DT will hopefully be in the near future). Perhaps one of the better versioning schemes I have tried is that contained in Near Time’s Flow application. Although this application is confusing to use, its versioning system is good.
I would definitely pay more for a well designed versioning feature.
Here are two more advanced scripts. The first one creates locked copies of selected contents in subgroups, the second one switches an old and the current version of the selected content.
-- Create new version
-- Created by Christian Grunenberg on Wed Feb 01 2006.
-- Copyright (c) 2006. All rights reserved.
tell application "DEVONthink Pro"
try
set theSelection to the selection
repeat with theRecord in theSelection
if type of theRecord is not group then
set theLocation to location of theRecord
set theLocation to theLocation & my replace_chars(name of theRecord, "/", "_") & " Versions"
set theGroup to create location theLocation
set theDuplicate to duplicate record theRecord to theGroup
set name of theDuplicate to (modification date of theRecord) as string
set locking of theDuplicate to true
end if
end repeat
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 tell
on replace_chars(this_text, search_string, replacement_string)
local od
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, search_string}
set the item_list to every text item of this_text
set AppleScript's text item delimiters to replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to od
return this_text
end replace_chars
-- Restore old version
-- Created by Christian Grunenberg on Wed Feb 01 2006.
-- Copyright (c) 2006. All rights reserved.
tell application "DEVONthink Pro"
try
set theSelection to the selection
if (count of theSelection) is not 1 or type of item 1 of theSelection is group then error "Please select one content."
set theRecord to item 1 of theSelection
set theLocation to location of theRecord
set theLocation to theLocation & my replace_chars(name of theRecord, "/", "_") & " Versions"
if (exists record at theLocation) is false then error "No versions have been saved."
set theGroup to get record at theLocation
if type of theGroup is not group then "No versions have been saved."
set theVersions to name of children of theGroup
if theVersions is {} then error "No versions have been saved."
choose from list theVersions with prompt "Select a version to restore"
if the result is not false then
set theVersion to item 1 of the result
set theDuplicate to child named theVersion of theGroup
set locking of theDuplicate to false
if exists parent 1 of theRecord then
move record theDuplicate to (parent 1 of theRecord)
else
move record theDuplicate to root of current database
end if
set name of theDuplicate to name of theRecord
move record theRecord to theGroup
set name of theRecord to (modification date of theRecord) as string
set locking of theRecord to true
end if
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 tell
on replace_chars(this_text, search_string, replacement_string)
local od
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, search_string}
set the item_list to every text item of this_text
set AppleScript's text item delimiters to replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to od
return this_text
end replace_chars
Thank you. I played around with these and the work really well. That they could be written is a testament to the power of Devon think’s scripting. That you did them for the users is a testament that you are really great! It’s part of what makes devon think such a great program to use–the fact that there’s such nice people behind it.
Thank you
erico
btw, anyone wanting a good example of a script to use to learn the logic of devon think’s storage system and its scripting abilities should study these scripts…
I also want to join the praise! Though I usually (as said above) don’t like scripts, these work extremely well. Unlike many other applications, this one gets better and better over time. Probably, like Erico said, because you really have attentive ears to the users problems and needs.
Could the Devonthink team create a place on the server to download and upload scripts? Not a message board, just the sripts with a description. I think it would be a great way to extend the usability of DTP and perhaps show those running DTP demo how scriptable it really is. More selfishly, it would save me from sifting through this message board to find all of your little gems. Thanks for all the new features through AS.
I was just pointed to this discussion from a question i asked in the usage scenarios by Annard. I know I’m coming in late, but I’d just like to cast my vote for a more built-in versioning system. The scripts are great; but part of versioning includes the basic ability to for the versions to be smaller than their normal size, and for there to be some basic comparison between previous versions. I have no idea how programming any of this would be, but even the ability to work with Subversion (and its like) vis-a-vis the DT database in v.2 might be sufficient, though something similar built in would be phenomenal. Since it’s open-source, maybe even a look into Subversion might be possible (you could pull an Apple, using open-source in a commercial app, ).
I understand and agree with the bloat-ware fears; but this would obviously be a “pro” feature for people who use DTpro as their information management backbone, and can really use these types of features.
The bloat fear is a very real one, given that DT is overwhelming for a newbie as is. Not to mention that more features means more code, which means more bugs and more testing, which in turn mean longer delays between versions and increased clost.
It seems that Christian is solving a lot of feature requests with scripts. This makes me wonder if it would be worth adding a single feature that would allow the user to invoke specific scripts from the Toolbar, Context Menu, and from user-specified hotkeys. That way “features” could be added or enabled through configuration, rather than increasing the size of the codebase.
Regarding versioning, I’m generally for it. I would much rather have the contents of the DT db checked into cvs or subversion, which should work fine with the 2.0 plans for a filesystem-based db.
At least the scripts menu can be already added to the toolbar. And it’s possible to define shortcuts by modifying the filename of the scripts - just add three underscores and the desired shortcut. For example “Demo___Cmd+Ctrl+A.scpt” gets the shortcut Cmd-Ctrl-A.
Another possibility to define shortcuts is of course to use System Preferences > Keyboard & Mouse > Shortcuts.
To put it more simple, what about the History function of the Zope zodb database: hold let’s say 10 versions listed with date/time of the last change, every list item a hyperlink to the full entry, plus a possibility to compare two of the versions (diff-like), plus a possibility to copy one of the older versions to the recent one.
This would be a medium between the scripts Christian presented and a full fledged versioning system, which maybe would be too complicated for the average user.