Skim has extensive support for scripting, such as AppleScript.
To add an Applescript to the menu, put it in Library/Scripts/Applications/Skim/
, either in your home folder or on your computer (if you want the script to be available for all users). You may have to create those directories if they do not exist. The scripts appear in the Scripts on the right side of the menu bar whenever Skim is the active application. You may have to enable the Scripts menu in the Script Editor preferences. You can also add AppleScripts to Skim's Script Menu. See Example Scripts for some scripts you could add there.
To see what is supported for scripting, open the Skim scripting dictionary in (Apple)Script Editor (File > Open Dictionary..., or Window > Library).
Due to bugs in (Apple)Script Editor (at least on some versions), some information is not (fully) displayed in the scripting dictionary. There are several dictionary types (such as "PDF view settings" and "document attributes") that are not included in the outline at the top view. But they are displayed in the lower pane when you select the Skim Suite. Several enumerated properties, such as color names (see below), are not displayed at all.
Skim's scripting supports access to the following classes:
application, window, document, page, note,
note preferences, PDF display preferences,
bookmark, download, outline, reading bar
A large number of properties for these classes are supported. The following actions are supported:
open, close, save, quit, count, delete, duplicate, exists, make, move,
revert, select, go, find, convert notes, read notes,
join, obtain, edit, grab, format, get selection for, preferences
You can save and export a PDF document directly from AppleScript. When you supply a file name argument (in
) to the save
command, this works like Save As (and changes the file name of the document). You can then also supply a file type argument (as
), in which case it works like Export (i.e. it does not change the file name of the document). The file type can be one of the following strings.
"PDF", "PDF Bundle", "PDF Without Notes", "PDF With Embedded Notes",
"PostScript", "PostScript Without Notes", "DVI", "DVI Without Notes", "XDV", "XDV Without Notes",
"Skim Notes", "Notes as Text", "Notes as RTF", "Notes as RTFD", "Notes as FDF"
Apart from these, also the names of any additional export templates can be used.
Skim scripting allows full control over the colors of notes and highlights. Colors are represented according to the RGBA (Red-Green-Blue-Alpha) model as a list of four integers, each one ranging from 0 to 65535 (= 216 - 1). For example, {65535, 0, 0, 65535}
represents the color red. You can also enter a color with less integers, in which case the integers are interpreted according to the RGB (Red-Green-Blue), GA (Grayscale-Alpha) or G (Grayscale) model. And then you can enter a large number of named colors as text. There are also many standard colors that can be entered by their name. Currently, the following colors are supported.
red, green, blue, yellow, magenta, cyan, dark red, dark green, dark blue,
banana, turquoise, violet, orange, deep pink, spring green, aqua, lime, dark violet,
purple, teal, olive, brown, black, white, gray, light gray, dark gray, clear,
under page background, window background, control background
Skim also has scripting support for selections. This can either be the selection shown by the document, but also selections handled by the script, for example as a result of a find
command to search for text, or to create a new highlight. Selections are modeled as a list of ranges of characters for the text on a page. For example,
{characters 1 thru 100 of text of page 1 of document 1 of application "Skim"}
If you enter this in a tell
block for the document, you can leave out the reference to the document
and the application
. Also, you can leave out the reference to the text
. Selections are supposed to be references, rather than a list of characters. Therefore you may have to explicitly tell the script to keep a reference, to avoid the script from evaluating the expression. This is in particular important when you want to assign a selection to a variable.
tell document 1 of application "Skim"
set aSelection to {a reference to characters 1 thru 100 of page 1}
end tell
To ease life a bit, AppleScript allows you to type 'ref
' as a shorthand for 'a reference to
'. Instead of character ranges, you can also enter selections using other types of text references. The standard Text Suite in the scripting dictionary for Skim describes ways to refer to components of a text. You can freely mix different reference forms inside a list describing a selection, as in the example below (As above, you should enter the following examples inside a tell
block and you may have to add references).
{character 1 of page 1, words 6 thru -1 of page 2, paragraph 1 thru 2 of page 4, every attribute run of page 5}
You can construct complex references to logically describe character ranges, for instance by nesting text references or using 'whose' specifications.
{character 1 of (every word of page 1 whose first character is "a")}
You may also enter a single range by itself, without wrapping it in a list, though AppleScript sometimes chokes on that, so it's better to always pass selections as a list.
You can manipulate selections using the join
command, which joins two selections to a single one. If the optional continuous selection
argument is true, the resulting selection will be a continuous range. The following returns a selection for the first three pages:
join first character of page 1 to last character of page 3 with continuous selection
You can also use the join
command with a single selection argument (so without the to
), to make a selection continuous or to normalize it.
As selections are not really objects, they cannot have properties. Still, there is some useful information to obtain from them. For that purpose the obtain
command can get certain 'properties' of the selection, determined by their type. Currently you can get (rich) text or RTF, a rectangle, a first and last index, and the page(s) for the selection.
You can use AppleScript to add new notes to a document. You use the make
command to accomplish this. It is important to note that notes, other than markups (highlight note
, underline note
, and strike out note
) need to be added to a page. You can do this either by adding the note inside a tell
block for the page, or by supplying the end of notes
of the page in the at
argument. Also to create a note, you have to supply the type of the note, unless you use the with data
argument. You can supply the type in the standard with properties
arguments of the make
command. Here are two examples.
tell page 1
make note with properties {type:text note}
end tell
make note with properties {type:anchored note} at end of notes of page 2
New markups (highlight note
, underline note
, and strike out note
) require in addition to the type also a selection to be initialized. This selection can also be passed in the with data
argument of the make
command. As notes are added to a single page, the markup is only added for the selection on the first page (just as for adding a markup from the Notes menu). As the selection already knows about the page, you do not need to explicitly mention the page (though you may). A highlight can be added as below, assuming the aSelection
contains a selection.
make note with data aSelection with properties {type:highlight note}
New freehand notes require in addition to the type also a path list to be initialized. A freehand note can be added as below, assuming the aPathList
contains a list of point lists.
make note with properties {type:freehand note, path list:aPathList}
You can access the view settings for the PDF document from AppleScript through the 'view settings
' property of a document
. View settings are packaged in a record, and can have the following properties.
scale factor, auto scales, display mode, displays page breaks, displays as book, display box
The 'display mode
' property can have one of the following values.
single page, single page continuous, two up, two up continuous
The 'display box
' property can have one of the following values.
media box, crop box
When you set the view settings, only the settings you provide in the record are changed. For example the script below only changes the display mode, showing one page at a time.
set view settings of document 1 of application "Skim" to {display mode:single page}
You can also access the document attributes of a PDF document (as displayed when you use Get Info) through the info
property of a document
. Document attributes are packaged in a record, and can have the following properties.
file name, title, author, subject, creator, publisher,
version, creation date, modification date, page count,
file size, physical size, logical size, page size,
encrypted, allows printing, allows copying,
keywords, keywords string
Here are a few example scripts to get you started (right-click on linked name to save, or option-click for download in most browsers).
sk://mccabe94#57
. Based on an idea from drosophiliac.Shift notes by X pages: Script to move all notes in whole document (or selected page range) by X pages forward or backward. Particularly useful when you want to delete some pages from the file, extract part of the file, or add new pages to it, because after doing any of these, original Skim notes will no longer fit the pages on which they should be. Runs with current Skim 1.5.9. Created by FurloSK at 11:13:44, 18 May 2020 (GMT).
Your scripts here?
Wiki: Interaction_with_Skim
Wiki: Main_Page
URL Fails for Digital Workflow for Academic Research In this blog you can find numerous original AppleScripts for integrating Skim with DEVONthink, BibDesk and other programs.
Solution: http://organognosi.blogspot.com/