Depending on the precondition, that all your objects are grouped and not combined into bigger groups themselves, here is how to do it. (I used cats in the example, because dogs were not available).
In the lower right you see a highlighted cat, object id 5358, which is a single path, so I added a green floor later which changed it to object 5364 which will occur later, so don't let confuse you. :)
You get the xml-editor by hitting button 4 from the right (arrow 1).
I changed g5358 to g-cat-5358 (field 4) to make it easy for a texttool to pick these objects which works for most elements which don't collide with xml-svg-names (color, meta, id, ...).
In the left window you see, that there is already a renamed entity, g-cat-5312 close to the top at the same indentation level.
Inkscape organizes unique ids for groups, but they don't need to be of the form gNUMBER, you can mixin other characters. Just don't pick an already existing identifier.
After changing the identifier, hit 'setzen (set)' (5) to confirm your change. You see a german interface here, YMMV.
Save the svg (as demo-cats.svg). We now switch to scripting.
for cat in $( grep g-cat- demo-cats.svg )
do
id=${cat//[^0-9]/}
echo $id
(head -n 53 demo-cats.svg; sed -n "/$cat/,/^ <\/g>/p" demo-cats.svg; echo "</svg>" ) > cat-${id}.svg
done
What does it do? It greps (search with grep) for the "g-cat-" pattern which is the start of our interesting section.
id=${cat//[^0-9]/}
extracts the id in bash from the expression. Echo prints it to the screen which should help to find the bug if something goes wrong.
head -n 53 demo-cats.svg takes the first 53 lines from the svg, which contains all the svg-boilerplate. Depending on your settings with different svg-formats (inkscape, compressed, normal svg, inkscape-compressed) this might vary.
With nl demo-cats.svg | less
you can numerate the lines, to find the right cutting point in your case.
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
^Up to this part, the lines should be included.
The next command is done with the stream editor sed: sed -n "/$cat/,/^ <\/g>/p" demo-cats.svg;
says (-n) no printing (but) searche for the cat group, up to the closing tag g at indentation level 2 which is 4 spaces before the </g>
if you didn't change Inkscape preferences, which you might remember if you did. Then add the closing tag for svg: echo "</svg>"
. Write the output to the file 'cat-$id.svg' (this overwrites silently existing files).
So I end up with two files: cat-5312.svg and cat-5364.svg .
A more elegant solution should be possible with xmlstarlet or similar tools, which are made to search and edit xml-files. Unfortunately I'm not used to it and did't get it working after reading 10 minutes of documentation. You wouldn't need to rename the groups in the beginning.