Hey ive drawn dozens of comics and I want to know, Is it possible to search for certain words typed in textboxes of all my files? Im at the point that its unpractical to look by eye
The good news is that SVG is just a text-based XML format, so can be searched using any normal text searching tools. The bad news is that text in an SVG file is structured something like this:
<text>
<tspan>This is a sentence</tspan>
<tspan>that is split over</tspan>
<tspan>multiple lines</tspan>
</text>
So if you try to search for something like "split over multiple lines" you won't find it, due to the code between "over" and "multiple". If this is likely to be a problem then you'll need a tool that understands XML structures, and can search for the "text nodes" within them. I can't make any suggestions as I've not yet needed such a tool, so have never gone looking for one.
Thanks so much, this is very insightful! Im going to try this soon
@Xav tough luck for me Im likely going to need to find that type of xml tool. Do you know what can I search it by on google? I cant even begin to figure out what to type haha.. Im not very tech savvy
I fear that if you're not very tech savvy, all the options you'll find will be overly complex. In terms of searching Google, you're trying to look for "text", "text elements" or "text nodes" in "SVG" or "XML" files. But most answers you'll find are about extracting a specific text node, rather than searching for strings that span multiple text nodes.
You'll also find that most XML tools assume you're a developer - or at least pretty clued up about the format and the terminology that surrounds it - and will offer far more complex capabilities than you need.
Within a web browser it's actually just a one-liner to extract all the text nodes from an SVG file and convert them into one long string, with spaces between them. Load the file, open the developer tools, and paste this into the console:
To find out whether a specific string is in there, you can add .includes('my string') at the end. So in my example above, finding the string "split over multiple lines" would look like this:
document.documentElement.textContent.replace(/\n/g, '').replace(/\s+/g, ' ').includes('split over multiple lines')
This will return true or false. Note that it's case-sensitive.
This is fine for a handful of files, but if you have loads of them then it becomes a chore, with no easy way to automate. That's when you start getting into the command line tools that require a lot more knowledge to operate.
I can't offer any better advice, I'm afraid. I'm a web developer, so if I needed to do this I'd probably write a web page that lets me load multiple SVG files, and apply the line above to each of them. But as a non-technical layman I think you'll find it very difficult to achieve what you want in a simple manner.
Thanks for those keywords Im still trying to wrap my head around the latter of the post but I think its best I start simple. Appreciate it, It will come handy as I figure my options for searching split words later.
Hey ive drawn dozens of comics and I want to know, Is it possible to search for certain words typed in textboxes of all my files? Im at the point that its unpractical to look by eye
If you are using Windows type this phrase into google : windows explorer 'find in files'
In Linux, there is generally a tab called 'content' or similar in the file manager search.
On Mac - I don't know.
The good news is that SVG is just a text-based XML format, so can be searched using any normal text searching tools. The bad news is that text in an SVG file is structured something like this:
<text>
<tspan>This is a sentence</tspan>
<tspan>that is split over</tspan>
<tspan>multiple lines</tspan>
</text>
So if you try to search for something like "split over multiple lines" you won't find it, due to the code between "over" and "multiple". If this is likely to be a problem then you'll need a tool that understands XML structures, and can search for the "text nodes" within them. I can't make any suggestions as I've not yet needed such a tool, so have never gone looking for one.
Thanks so much, this is very insightful! Im going to try this soon
@Xav tough luck for me Im likely going to need to find that type of xml tool. Do you know what can I search it by on google? I cant even begin to figure out what to type haha.. Im not very tech savvy
I fear that if you're not very tech savvy, all the options you'll find will be overly complex. In terms of searching Google, you're trying to look for "text", "text elements" or "text nodes" in "SVG" or "XML" files. But most answers you'll find are about extracting a specific text node, rather than searching for strings that span multiple text nodes.
You'll also find that most XML tools assume you're a developer - or at least pretty clued up about the format and the terminology that surrounds it - and will offer far more complex capabilities than you need.
Within a web browser it's actually just a one-liner to extract all the text nodes from an SVG file and convert them into one long string, with spaces between them. Load the file, open the developer tools, and paste this into the console:
document.documentElement.textContent.replace(/\n/g, '').replace(/\s+/g, ' ')
To find out whether a specific string is in there, you can add .includes('my string') at the end. So in my example above, finding the string "split over multiple lines" would look like this:
document.documentElement.textContent.replace(/\n/g, '').replace(/\s+/g, ' ').includes('split over multiple lines')
This will return true or false. Note that it's case-sensitive.
This is fine for a handful of files, but if you have loads of them then it becomes a chore, with no easy way to automate. That's when you start getting into the command line tools that require a lot more knowledge to operate.
I can't offer any better advice, I'm afraid. I'm a web developer, so if I needed to do this I'd probably write a web page that lets me load multiple SVG files, and apply the line above to each of them. But as a non-technical layman I think you'll find it very difficult to achieve what you want in a simple manner.
Thanks for those keywords Im still trying to wrap my head around the latter of the post but I think its best I start simple. Appreciate it, It will come handy as I figure my options for searching split words later.
If anyone can help me out still? Im trying to follow this more simple method of using windows explorer http://www.simplytraining.co.nz/how-to-search-for-words-within-files-on-windows-7/ And I type content:broke in the search bar and noting shows up, Im on windows and all my fires are saved as svg what could I be doing wrong?