Inkscape’s command line is not limited to GUI-less export, conversion, and querying tasks. You can script a certain share of regular editing tasks as well. This is done by the --verb
command-line parameters, which make Inkscape start as usual (with a GUI) and run the specified sequence of verbs on the objects which you select with --select
. When done, Inkscape does not quit (unless you use the FileQuit
verb) but simply stops and allows the user to continue editing.
A verb typically corresponds to a command that you chose from a menu. It is not a one-to-one mapping, however; some verbs are not available via the menus. On the other hand, many verbs require further interaction from the user, such as adjusting parameters in a dialog; it makes little sense to use them in your script except as a last step, so that the user can “continue from here.”
To get a complete list of verbs your version of Inkscape supports (there are more than 750 verbs in version 0.47), run Inkscape with --verb-list
. Here’s just the very top of the list, showing some verbs commonly used in scripting. The verb names are before the “:” and followed by a brief description:
$ inkscape --verb-list FileNew: Create new document from the default template FileOpen: Open an existing document FileSave: Save document FilePrint: Print document NextWindow: Switch to the next document window PrevWindow: Switch to the previous document window FileClose: Close this document window FileQuit: Quit Inkscape EditCut: Cut selection to clipboard EditCopy: Copy selection to clipboard EditPaste: Paste objects from clipboard to mouse point, or paste text EditPasteStyle: Apply the style of the copied object to selection EditPasteSize: Scale selection to match the size of the copied object
Apart from the regular Inkscape commands, all preset filters (17.3 Preset Filters) and extensions (13.3 Path Extensions) have two verbs each: One is the same as running this filter or extension from the menu (which may or may not display a dialog with parameters); the other, with .noprefs
appended, always runs without a dialog, using default values. For example:
org.inkscape.effect.filter.filter2573v: Glossy clumpy jam spread org.inkscape.effect.filter.filter2573v.noprefs: Jam spread (No preferences) org.inkscape.text.uppercase: UPPERCASE org.inkscape.text.uppercase.noprefs: UPPERCASE (No preferences)
For scripting, of course, the .noprefs
variants are preferable.
Usually, one or more --verb
parameters in a command-line script are preceded by a --select
parameter which selects some object by its ID. You can specify multiple --select
parameters to select multiple objects. If you want to do something to all objects at once, or to objects one by one, you don’t need --select
; instead, just use the verbs --verb=EditSelectAll
or iterate through the objects with --verb=EditSelectNext
.
Here are a few examples. Open the document, select all objects, convert them to paths, save the document, and quit:
$ inkscape a.svg --verb=EditSelectAll --verb=ObjectToPath --verb=FileSave \ --verb=FileQuit
Open the document, select a specific group by ID, ungroup it, save, and quit:
$ inkscape a.svg --select=g2038 --verb=SelectionUnGroup --verb=FileSave \ --verb=FileQuit
Open a document, select an object by ID, copy it, select another object, paste style, remove any filters it may have had, apply a Pixel smear preset filter, save, and quit:
$ inkscape file.svg --select=text2328 --verb=EditCopy --verb=EditDeselect \ --select=text2322 --verb=EditPasteStyle --verb=RemoveFilter \ --verb=org.inkscape.effect.filter.filter3707-6-6-0.noprefs \ --verb=FileSave --verb=FileQuit