Ubuntu – How to open a new file from the command line with Inkscape

command lineinkscape

I can't find how to open a new svg document with Inkscape, simply from the terminal.

If the document specified as argument (or via -f) does not exist, there is just an error saying it doesn't exist, and then it opens an unsaved new document.

I tried using the verb FileSaveAs like this for example:

inkscape --verb FileSaveAs mynewfile.svg

but FileSaveAs does not take arguments, it just opens the graphical window for this action.

I might be persnickety, but I would find it more convenient to be able to create a new file directly from the command line instead of having to launch this window and click to the right directory…

Best Answer

To my surprise, there seems to be no option in Inkscape to produce a new file from cli!

How to create the option?

As always, if it doesn't exist, it can be made:

  1. Open Inkscape, create a new file drawing.svg
  2. Save this file anywhere
  3. Copy the code below into an empty file, save it as newinkscape (no extension) in ~/bin. Create the directory if it doesn't exist yet.

    #!/bin/bash
    
    sample="/path/to/drawing.svg"
    dr=$1
    
    cp "$sample" "$dr"
    inkscape "$dr"
    

    Make the script executable

  4. Replace in the line:

    sample="/path/to/drawing.svg"
    

    The path by the path to your sample file.

Log out and back in, now:

newinkscape /path/to/newfile.svg

will open a new empty Inkscape file, saved in the location you used in the command.

Related Question