How to automatically add prefix to all svg IDs

Asked by Alex on 2018-08-17

Hello. I run into an issue, when I use few svgs in my html document. I`m doing animations on it, and placing it inline into html. But the problem is, svg contains a lot of important IDs: for gradients, clipping paths and so on. As a result, IDs conflict between different svg files.
My question is, whether the possibility exists to add some prefix before every ID inkscape creates? For example, i have:
path style="fill:url(#path152_1_)"
and I would like to have it automatically done in this way:
path style="fill:url(#someprefix_path152_1_)"

Thank you a lot!

Question information

English Edit question
Inkscape Edit question
No assignee Edit question
Last query:
Last reply:
Hachmann (marenhachmann) said : #1

No, currently there is no way to do that in Inkscape.

However, if you open up your SVG image in a text editor before importing it into another drawing, you can:

- search for 'fill:url(#'
- and replace it with 'fill:url(#some_prefix_'
(this works inside Inkscape, too, with Ctrl+F)

- search for 'linearGradient id="'
- and replace it with 'linearGradient id="some_prefix_'
(this does not work in Inkscape's search and replace dialog)

Can you help with this problem?

Provide an answer of your own, or ask Alex for more information if necessary.

To post a message you must log in.