Learning scripting DT4 / Conversion of DJVU files to PDF

I have two related questions:

  1. What is the best source for learning scripting for DT4, and is AppleScript the most suitable scripting approach in DT4?
  2. I am looking to convert DJVU files in DT4 into PDF + OCR and then archive the source. What would be the best starting point to achieve this goal?
  1. This is somewhat of a question of preference. However, in-house we use AppleScript. These forums, DEVONthink’s built-in scripts, and the Automation chapter of the are the best teachers for DEVONthink-specific scripting. However, you can find info on forums like MacScripter, the Automators, and Late Night Software’s.
  2. DJVU files aren’t directly convertible via OCR. They’d need to be converted to PDF first. We cannot vouch for it but you may be able to use…

… to convert them. However, I would process the files outside your database before importing as PDF.
By the way, where did you get DJVU files?

Thanks a lot! That’s very useful, I’ll have to invest some time working with AppleScript. For conversion, I fully agree, first conversion to PDF and only later OCR if necessary.
Now to be honest I don’t recall where I got the djvu files from, I had a few very old books (mostly about math) scanned into djvu and since I am moving my library to DT4, I wanted to convert them, and as I moved them inside DT4 already, I was “brilliantly” thinking that I could create some conversion script in DT4 :smiley:

You’re welcome!

I was “brilliantly” thinking that I could create some conversion script in DT4 :smiley:

You could create a script that runs within DEVONthink. However, since this is likely a one-off project, I’d say it’s easy enough to just run from Script Editor. And you could include importing into DEVONthink in the same script.

If you opted to use the djvu2pdf commandline tool in the script, you’d use a do shell script AppleScript command. But it would be easy enough to just open Terminal.app and convert the files in the shell and import the PDF documents after the fact.

In my opinion (which is a minority in the Appleverse), JavaScript is more suitable than AppleScript – for all OSA tasks, not only DT scripting. AppleScript is underspecified (lacking any formal grammar) and lacks even remotely modern features like string processing, regular expressions, array methods, advanced data types, and introspection.

OTOH, JavaScript for Automation (JXA) is as dead in the water as AppleScript, since Apple stopped development for both technologies years ago. And JXA is more buggy than AppleScript, its ObjectiveC bridge is lacking some features. There are far fewer online resources for it than for AppleScript, my Scripting with JXA | JavaScript for Automation (JXA) being one.

JavaScript as such (ie the language, not the additions by JXA) is widely used everywhere from websites to server-side programming and desktop scripting (think node.js). It is also available as the JavaScriptCore engine in iOS and macOS and used by some apps like Drafts on both platforms. So, learning it might provide more useful than AppleScript, which is strictly limited to automating macOS apps. Neither AppleScript nor JXA exist on iOS.

As @BLUEFROG said: The choice between AppleScript and JavaScript is a matter of preference. If you do have some programming experience, AppleScript might not be for you (at least, it never was for me).

3 Likes

As for writing AppleScript scripts, check out ScriptDebugger, which is now a free download.

1 Like

This is indeed an option, but can also be daunting for a new coder. I have scripted 99% in Script Editor for decades, including for corporations :slight_smile:

1 Like