Bates numbering of pdfs from within Devonthink

Bates numbering is a numbering system used by lawyers to identify documents. A Bates number has two components:

  • A prefix which identifies the set of documents, such as “DD” for defendant’s discovery.
  • A zero prefixed string, traditionally 4 digits in length such as 0090

This post outlines a scheme for attaching Bates numbers to individual documents in DT and two scripts for implementing it. The first script applies “virtual” Bates numbers, in essence applying the Bates numbering as metadata to the document, and the second script modifies the PDF by imprinting the Bates numbers sequentially onto the PDF.

A bates number in DT is a prefix of any length and a number of any length.The following would all be examples of acceptable number formats:
A000030, WER0078, 2E9500
This number is inserted as the first part of a spotlight comment and terminated with the “" character. The "” character does not form part of the Bates number but serves simple as a marker between the Bates number and the remainder of the spotlight comment

To manually apply a Bates number to a document, click in the spotlight comment column (if its visible) or open the the info pane and enter the Bates number so that it looks something like this:
“A0100_The text of the spotlight comment”

Applying Bates numbers in batches

The script will then sequentially apply the Bates number to each document. Thus, using the example above, the first document would have the Bates number A0100 in the spotlight comment field. If the first document has 10 pages then the second document will have a Bates number of A0110 and so on. The script will retain any existing spotlight comments.

When the Bates numbering has been applied and checked, for example against an index of the documents, the Bates number can be imprinted onto the documents.

Imprinting the Bates number onto a pdf

(This script requires that you have PDFPen Pro installed. It works by passing off each document in turn to be imprinted by PDFPen and resaving the document into DT)

The script will give you a dialog box allowing you to choose the position of the imprint, the colours and the size of the font.

Apply Bates number.jpg

When the script has been completed (which may take a while depending on the number and length of the documents), each page of each document will be imprinted with a sequential Bates number.

Support in other scripts
This Bates numbering scheme is supported in a number of other scripts.
The Annotation Pane will add the Bates number of the referenced page in the source document to the spotlight comment of the annotation document.
This spreadsheet will separate out the Bates number and spotlight comments as separate columns which is useful for the production of indexes.
Citations exported to Omnioutliner will contain the Bates number as part of the citation format

Frederiko

Thank you for these scripts! I’m can think of a number of cases where they will be helpful beyond the legal context.

I suggest, for future compatibility, using these 4-letter ID forms for the “tell” statements:


tell application ID "DNtp"

and


tell application ID "PDFp"

Wow - could’ve used this several years back! :laughing:
[Although the same is true of my Mac, and DTPO!] :smiley:

Fantastic Script! Works well. Many thanks!

Could you please confirm the following:

If you are selecting multiple records, is the order of the numbering done according to the order in which the records were selected, or on the basis of some other criteria (name of the record etc.?)

The 3rd script to clean out the Spotlight comments - is it looking for the underscore “_”, and removing the text inside the Spotlight comment immediately preceding and including the underscore? Just trying to understand the mechanics thereof – it worked as explained!

Thanks again!

In reply to Cassady

I am pleased if the scripts are helpful. Its a little payback to the fantastic DT community on these forums.

The ordering of the records is the order they appear in the DT list of documents. In other words if you switch the list order to unsorted, manually rearrange the order of documents, and select the same documents again, the documents will be numbered according to the new order in the DT window. I always want my documents to appear chronologically so I sort them in the DT window first by date created and then apply the numbering.

An underscore at the character immediately following the prefix and the number i.e the 9th character in the default, is the marker for the script to know that the spotlight comment contains a bates number that must be removed. I made the assumption that most people arent going to use a lot of underscores in their comments.

These scripts will become trivial the day DT gets real metadata. Most of the scripts are concerned with trying to determine if there is already a spotlight comment in place and accounting for it.

Frederiko

As I understand it this script inserts a consecutive Bates number on every page in a PDF and I can very much see the use of this for me, there is, however, a very big “but” for me in that it depends upon having PDFPenPro installed :frowning: I do not and can not justify the cost of buying it. Could the script be adapted to achieve the same result without having PDFPenPro installed, with Skim would be ideal?

Hello Allsop,

I haven’t seen anything in Skim’s applescript that would allow you to do this.

The best option for doing this without PDFPenpro is to use the very good scripting addition from http://www.satimage.fr/. It has applescript commands to imprint text on a pdf.

There is a whole section and examples in “Learn AppleScript
The Comprehensive Guide to Scripting and Automation on Mac OS X” by Hamish Sanderson & Hanaan Rosenthal starting at page 908 that deals with using Satimage to add text imprints to a pdf. It looks pretty straightforward and is probably only an hour’s work to adapt the script to use the Satimage library instead. Its possible to call the Smile application itself from DT itself.

Frederiko

How do you get the script to imprint the actual PDF’s? I can see the bates numbers in the spotlight comments but the docs aren’t not imprinted. I have PDF PenPro but I am trying to avoid having to open each document separately just to stamp the documents. Thanks, and you guys are awesome!

Hello Nathan,

I have updated the instructions and the scripts in the first post. Hopefully it should be clearer. let me know if you need any more help with it.

Frederiko

Frederiko - you rock! Thanks so much for your help. Works perfectly!!!

Hi,

This script is apparently no longer downloadable. Do you have another URL for the link?

The links have been updated.

Frederiko

Thank you!

These two scripts were working for me last week, but now stopped working. Could it be the update to High Sierra has changed something? Can anyone else who uses the script let me know if they are able to use it?

I haven’t upgraded to High Sierra yet so I can’t test them I am afraid. Given the botched mess that Apple made with PDFkit in Sierra, I won’t upgrade for several months until I know all my critical apps are updated. The AppleScript listserv has quite a few people flagging odd broken AppleScript interactions.

That being said I will do what I can to try and find out why they are failing.
Could you let me know in what way the scripts are failing. The virtual numbering script is very straightforward and uses only DT’s scripting objects, so I doubt High Sierra would break it.

The imprint script is more complicated relying on both Pashua and PDFPen Pro. Does this script fail before presenting the pop up box or fail to imprint the numbers? Are there any error messages?

Frederiko

So I installed the latest supplemental update / patch which Apple put out, and now the scripts work fine again. FYI, there were no error messages when it was failing. I heard the ‘trash can’ noise like it was doing its thing, and then nothing.

But now it’s working. (Very weird).

This is an old thread, but when I tried using this script on Catalina I received a syntax error: “A property can’t go after this identifier.”

And “thePage to page” is highlighted.

Anyone have any thoughts as to what I’m doing wrong or whether the script might need to be updated for Catalina+?

Thanks!

You could also create a template for imprinting (see Preferences > Imprint) which supports placeholders (e.g. bates number).

1 Like

Thanks! That is a very impressive feature. Looks like the script remembers the last number used and continues the sequence on the next use.

This is exactly what I needed. I appreciate the help.

If I don’t want to start at 1 (because there have been previous productions), is there a way to tell the script to start with a different number?

I suppose I could insert a dummy PDF as the first document with the previous number of pages produced, but want to confirm there wasn’t any easier way to do it.

Thanks!

It seems there is only one sequence and I’m unable to reset that Bates Number placeholder back to zero. How can I reset the Bates Number sequencing? Is there one sequence per Database?

I’d like to learn more about the Bates Number placeholder but don’t see much information in the Help section.

Thanks!