How can I convert all .svg files in a directory to .pdf on Linux in the commandline

6

3

When I have a directory full of .svg files, e.g. from Inkscape, how is it possible to convert them to .pdf files?

Similar to this approach for a single file, but as a batch command for a whole directory.

user36028

Posted 2019-01-10T09:19:49.213

Reputation: 171

1

Possible duplicate of How do I convert an SVG to a PDF on Linux

– n8te – 2019-01-10T09:21:00.450

Answers

11

In this post, the procedure is shown for a single file.

The relevant command is:

rsvg-convert -f pdf -o t.pdf t.svg

For a whole directory, a simple bash script does the job:

for i in *.svg;do rsvg-convert -f pdf -o ${i%.*}.pdf $i;done

This assumes that you have rsvg-convert installed, if not you can get it by typing:

sudo apt-get install librsvg2-bin

user36028

Posted 2019-01-10T09:19:49.213

Reputation: 171