CaseLeaf

Handbook / The `find` command

The find command

A clause has to be checked across every contract in a folder, and you need to know which ones mention it and where.

Reports where a phrase appears, with the line it sits in and the sheet it is on. It is not a search box: it answers in a form a script can use, so it is what you reach for when the question is does this document say X, and where, asked of many documents or asked repeatedly. The surrounding line is included because a page number alone rarely settles the question that prompted the search.

How you run it

caseleaf find report.pdf --for "force majeure"

caseleaf find report.pdf --for "force majeure" --regex

What each part means

In full, every part it will take:

caseleaf find <file> --for <text> [--regex]
part what it is for
<file> The PDF to work on, as a path, such as report.pdf beside you, or the full path to it. It is read and not written.
--for The words to look for, in quotation marks if they contain a space, as in --for "force majeure". Every occurrence on every sheet is reported, with the line it sits in.
--regex Read --for as a pattern rather than as words, so --for "cl(ause|auses)" --regex finds both. Left out, the words are looked for exactly as given.

The Find bar's own search, regex mode included.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "for" : "force majeure",
  "found" : 2,
  "regex" : false,
  "where" : [
    {
      "line" : "A clause about force majeure, and what follows from it.",
      "page" : 1,
      "says" : "force majeure"
    },
    {
      "line" : "Schedule B lists the force majeure events in full.",
      "page" : 2,
      "says" : "force majeure"
    }
  ]
  … and the rest of the answer

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "find" on "/path/to/report.pdf" ¬
        options "--for \"force majeure\""
end tell

tell application "CaseLeaf"
    perform "find" on "/path/to/report.pdf" ¬
        options "--for \"force majeure\" --regex"
end tell

All the commands · Asking from a script · Contents