Thursday, 7 May 2009


Wow it's been a while since I've update this!

I have several images that I got from Cisco that are in EPS format and I wanted to use them in Inkscape for diagrams, etc. They're public domain, so I wanted to see if I could give them back to the Open Clip Art Library once I was done.

I got them from the Cisco site but couldn't find anything that could easily convert them on the command line. The ways I found involved converting to PDF and importing in Inkscape. The best way was loading them in Scribus and exporting as SVG, which worked fine, but do that with 300+ files!

In the end I found that I could use pstoedit to convert to another format and then from that format to svg. This worked flawlessly and I didn't even encounter any problems on the final svg file like the website claimed there would be.

This is what I did:

for EPS in *.eps ; do FIG=`echo "$EPS" | sed -e s/eps$/fig/` ; SVG=`echo "$EPS" | sed -e s/eps$/svg/` ; echo "Converting ... $EPS" ; pstoedit "$EPS" -f fig "$FIG" ; fig2dev -L svg "$FIG" cisco_svg/"$SVG" ; rm -f "$FIG" ; done
It worked like a charm.


(Note: I've fixed the script. Thanks to Nelnik pointing out in the comments that my sed for /eps/fig/ would convert steps.eps into stfig.eps. This is due to me not being specific enough. Adding the $ at the end of the /eps/ makes it look specifically for something ending in eps. This would match the extension only in steps.eps.)


E.D.M. said...


Jeepers, that went over my head... Is that a bash script?


Mike P said...

That recipe rocks... thank you. I didn't have transfig installed, so I had to install that before the script worked.

Un Mexicano said...

Great Job!, Im becoming a fan of scripts, I saves me a lot of time in repetitive and boring tasks.

Just an "obvious" comment

In order for this script to work, it needs execute +x permissions and a "file folder" named cisco_svg at the same level of the script, but you can always change this option by editing the script.

You Rock,

Greetings from Mexico city.

Christian said...

Worked like a charme! Thanks a lot!

Nelnik said...

In the line:
do FIG=`echo "$EPS" | sed -e s/eps/fig/` ;

if you have a file called "steps.eps",
will that name become "stfig.eps" ?

Patrick Bulteel said...

Nelnik: Thanks for the comment. You are right and I've corrected the post. (It seems to be a popular one.)