CaseLeaf

Handbook / The `rename` command

The rename command

A script has just produced a document and it has to be filed under the matter it belongs to.

Gives the document another name, or moves it to another folder. It exists so a script that has just produced something can file it without leaving the application. It also means the document's own record knows it moved, which a filesystem move does not tell it.

How you run it

caseleaf rename report.pdf --to Reviewer

What each part means

In full, every part it will take:

caseleaf rename <file> --to <name or path>
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. This command writes to it, so keep a copy if the original matters.
--to Where to write the result, as a path. The shape above shows which format this command writes. This command needs it, and writes only there: the document you named is left exactly as it was.

The extension is put back when it was left off, and never doubled when it was not. Nothing is ever overwritten: a name something else already answers to is refused rather than taken.

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.

{
  "from" : "report.pdf",
  "name" : "Reviewer.pdf",
  "renamed" : true,
  "to" : "Reviewer.pdf"
}

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 "rename" on "/path/to/report.pdf" ¬
        options "--to Reviewer"
end tell

All the commands · Asking from a script · Contents