How do I merge all .svgs in a folder into a .pdf?

I have a lot of .svgs. I found this solution:

for file in *.svg; do inkscape "$file" --export-filename "${file%svg}pdf"; done

Is it safe? Also, is there a better way to do it?

Seems a bit too heavy.
And … if I’m not wrong that will convert each file into a pdf, but not merge them.

(oh, upon looking at the medium article there is a second step merging all the files, so ok)

I dont know what tools you have.

This can be done oh so many ways.

Lets use different tools in this example…

(we also assume you are currently in the directory)

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

The above relies on librsvg (rsvg-convert) and poppler (pdfunite)

1 Like

Essentially, you want to end up with one (1) pdf document
that will contain each one .svg graphic per page in the document?

And now you are questioning whether the command that is supposed to achieve that goal

… is safe to run?

You are questioning to try and test what the outcome would be?

Are you implying that running that command would be possibly unsafe?

… why? :grimacing:
just try and evaluate the result

There are probably better (at least: different) ways to do it, though.
But the command does not alter the original - so you could always … try again. :wink:

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.