Can I create and open a file with inkscape from command line?

Post questions on how to use or achieve an effect in Inkscape.
cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Can I create and open a file with inkscape from command line?

Postby cheflo » Sat Apr 22, 2017 12:37 am

I often use command line programs to create and open a file with one comman, e.g.

Code: Select all

vi new-file-name
I tried doing this in inkscape

Code: Select all

inkscape new-file-name.svg
but it does not work unless the file is already created.

Is there a way to create and open files in inkscape with only one command? Or do I have to launch the gui first and then click through the save menu to create the file? I saw this, but it is unreliable for me for some reason https://askubuntu.com/questions/860533/ ... h-inkscape.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Can I create and open a file with inkscape from command line?

Postby Moini » Sat Apr 22, 2017 12:49 am

You could open a template file, just like Inkscape does when it creates a new document. Maybe use a copy of the standard 'default.svg' (don't overwrite the original ;-))?

But I'm not sure what you'd want to do with an empty file - Inkscape command line is limited to anything that doesn't need parameters and is available via the menu. You could create an extension that does what you want, but that would essentially mean to re-write functionality that Inkscape already has. It's a bit painful...

What do you plan to do with the empty file?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

cheflo
Posts: 8
Joined: Fri May 27, 2016 4:27 am

Re: Can I create and open a file with inkscape from command line?

Postby cheflo » Sat Apr 22, 2017 1:24 am

Thanks for the reply!
Basically, I just want the file to be save at the current location and opened in inkscape. So if I navigate to a directory via the command line, I can just launch `inkscape new-file-name.svg`, to create a file that I can start editing in inkscape, and when I press Ctrl+S, the file is saved in the current directory where inkscape was launched from, instead of having to click through the save menu to find this directory again.

I guess my current solution is similar to what you are suggesting. I have created and "empty" svg file, and I have set up an alias that will copy this file to the current directory and then rename it. Then I launch inkscape on this newly created file. Is this similar to your suggestion or do you have a more efficient way of creating templates with inkscape?

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Can I create and open a file with inkscape from command line?

Postby Moini » Sat Apr 22, 2017 1:54 am

Yes, I think it's the same concept (but yours goes farther with the alias, allowing you to use Ctrl+S instead of Shift+Ctrl+S).
Happy CLI' ing :-)

(maybe worth a feature request, though? Perhaps with an additional parameter for 'create new', to not break existing behaviour?)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)


Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Can I create and open a file with inkscape from command line?

Postby Moini » Thu Nov 02, 2017 1:00 am

There has just been something implemented that will probably serve that purpose. You can now (in 0.93, that is), indicate a name for saving as Inkscape SVG:

https://bugs.launchpad.net/inkscape/+bug/1572242
https://gitlab.com/inkscape/inkscape/co ... 56d9800dfc
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)


Return to “Help with using Inkscape”