Save multiple objects from vector file to separate files using Inkscape/OS/Freeware


Question

I have a downloaded vector file (AI format). The file contains simple vector images of various dog breeds. I've loaded the file in inkscape,ungrouped them and would like a way to save out each dog vector as a separate file. Is there a way to automate this with Inkscape or some other OS/Freeware tool? Otherwise I'll have to select each and Save as. Any help is most appreciated!

UPDATE Thanks to JSBueno for the advice on editing the actual SVG file. I didn't realize that SVG was just an XML file. I should be able to easily walk through the file and export out each dog as a separate file. This, by the way, will be way faster than doing it through the interface which was the goal of this post. Thanks to all for the advice.

1
8
4/24/2015 2:46:00 PM

There are two solutions that I have found for exporting multiple objects from Inkscape as SVGs. These methods have the benefit of being scripts that can be run automatically and don't need editing of SVGs in text editors.

  1. svg-objects-export

The svg-objects-export script works by exporting all objects based on regular expressions. In your case it would work by exporting all objects with a particular ID. To use it first clone or download the script from Github.

In Inkscape you need to change the ID of all the objects you want exporting to have the same filename pattern. To do this open the Object Properties dialogue by going to Object > Object Properties or pressing Ctrl+Shift+O. In the ID field change them all to have the same basename ID e.g. Dog_1, Dog_2, Dog_3 etc (objects cannot have the same ID).

enter image description here

With the file saved and the script downloaded, in a terminal run the following command

python svg-objects-export.py --pattern 'Dog_*' /path/to/your/file.svg

This will export all of the objects with the basename ID "Dog_".

  1. inx-exportobjects

The inx-exportobjects inkscape extension will simply export all selected objects. To use it first clone or download the extension from Gitlab. To install it copy the files export_objects.inx and export_objects.py to .config/inkscape/extensions/. In Inkscape you'll have an option called "Objects to Files..." in Extensions > Exports. Select the objects you want to install and select this option.

enter image description here

In this dialogue box simply change the Export Directory to the place where you want to save your files and change the Basename to the new name of the files and then press Apply.

enter image description here

The files will be exported to your specified directory.

Each of the solutions have many other options, such as animated gif export, which you should definitely experiment with.

5
12/27/2017 8:08:00 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow


Website under construction!!!
^