Command prompt / batch file

Discussion about writing code for Inkscape.
[email protected]
Posts: 2
Joined: Fri Jan 29, 2016 4:16 pm

Command prompt / batch file

Postby [email protected] » Fri Jan 29, 2016 4:35 pm

Hello @ all.
I don't know if this is the right place to ask this questions. But maybe here's a coder/programmer
who knows about my problem:

When I try to merge two svg-files with the following command:

"c:\Program Files\Inkscape\inkscape.exe" --file=C:\temp\file1.svg --verb FileImport="C:\temp\file2.svg"

Inkscape opens the first file but it doesn't import or opens the second, which should be merged in the same document.

I tried with v. 0.91 under 2012r2 and windows 10

Thanks a lot
Chris

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

Re: Command prompt / batch file

Postby Moini » Sat Jan 30, 2016 12:14 am

Hi Chris - did you see the answer I gave in the German forum? ;)

You've got a syntax error in your command:
add a

Code: Select all

=
behind

Code: Select all

--verb


and verbs don't take arguments, unfortunately.

I'm not sure if it might be possible to maybe *copy* contents from one Inkscape instance to the other... Or maybe ~suv has a hint about how this might possibly be automated.
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)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Command prompt / batch file

Postby ~suv » Sat Jan 30, 2016 3:22 am

As already mentioned by Moini, this is not valid syntax:

Code: Select all

--verb FileImport="C:\temp\file2.svg"
and cannot work (Inkscape verbs do not take arguments).

Inkscape does not support non-interactively merging multiple SVG files on the command line.

Alternative options (tools, or libraries to build your own script) can be found e.g. on github:
  • svg_stack (python): svg_stack combines multiple SVG elements into a single SVG element. It can be called from the command line (less flexible) or called from the Python interface (more flexible).
  • svg_utils (python): This is an utility package that helps to edit and concatenate SVG files. It is especially directed at scientists preparing final figures for submission to journal. So far it supports arbitrary placement and scaling of svg figures and adding markers, such as labels.
Depending on the actual use case, maybe a js-based tool would serve you better (?):
  • svg-merge (npm): Merge a folder of svg files into a single file
  • svgshelf (npm): A simple CLI for merging multiple svg into a single file, for nodejs/iojs.
Else I'd recommend you to search sites like github yourself with appropriate keywords for your use case (e.g. svg sprite on github), or provide more details here in this topic (someone might be aware of a solution specific to the use case).

[email protected]
Posts: 2
Joined: Fri Jan 29, 2016 4:16 pm

Re: Command prompt / batch file

Postby [email protected] » Mon Feb 01, 2016 3:45 am

Thanks a lot for all the answers.
I found out that a simple dos copy /b file1.svg + file2.svg result.svg did the job (for my specific problem).
Because svg is just xml.
But I don't know, if it works on all different svg's with non unique headers for example.
Many Thanx
Chris

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

Re: Command prompt / batch file

Postby Moini » Mon Feb 01, 2016 6:06 am

I doubt that will be a valid svg... Sounds like it would just collate them, thus resulting in basically two independent svgs in a single file. Does Inkscape open that? Might work if embedded in a website.
(tried by duplicating a file - nope, Inkscape only shows the first of the two, no matter if they're different or not). Firefox doesn't even open the 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)

ShawnWDion
Posts: 70
Joined: Fri Apr 22, 2016 8:32 am

Re: Command prompt / batch file

Postby ShawnWDion » Tue Apr 26, 2016 10:44 am

To get your SVG's to work check out SVGSplit you can either use the site or get the files from the github and run it locally this will let you have the parts you want to DOS merge


Return to “Programming”