13

I have around 150 SVG files created in Inkscape. Is there is a utility that can export all of these to multiple PDF or PNG files?

Exporting individually is too time consuming, so I was wondering if I could do it in a batch with some utility/software.

Windows preferred.

7 Answers 7

10

For people who landed here from a google search because this question references Inkscape but isn't tagged with Windows, here's a complete howto for Linux (this assumes you have Inkscape installed on your system - tested on Ubunut 14.04 with Inkscape 0.91).

Create a file in the directory where you want to convert your SVGs to PDFs. (I used gedit below but you might as well replace it the text editor of your choice)

gedit convertSVGtoPDF.sh

Paste the following code inside

#!/bin/bash
mkdir export_dir
for file in *.svg; do
    filename=$(basename "$file")
    inkscape "$file" --export-type=pdf --export-area-drawing --export-dpi=1200 -o "export_dir/${filename%.svg}.pdf"
done

Save the file.

Note: Changes you can make to the script above.

--export-type can be one of: [svg,png,ps,eps,pdf,emf,wmf,xaml]

--export-dpi is just the dots per inch number you want on the new file

--export-area-drawing will export only the drawing. If you want the page instead, use --export-area-page

For older versions of Inkscape, before 1.2, the -o flag should be replaced by -A.

Now make this script executable

chmod +x convertSVGtoPDF.sh

And execute it inside your directory containing the SVGs

./convertSVGtoPDF.sh

This will create a new folder called export_dir where you can find your PDFs with embedded fonts.

Happy Inkscaping!

5
  • Hi A__, welcome to GDSE and thanks for your answer. If you have any questions, please see the help center or ping one of us in the Graphic Design Chat once your reputation is sufficient (20). Keep contributing and enjoy the site!
    – Vincent
    Sep 22, 2015 at 11:49
  • This would also be possible on Windows using a batch script of powershell, although it is worth mentioning this minor quirk about the Inkscape command line under Windows. Sep 22, 2015 at 11:57
  • This worked for me except I had to remove $PWD/. It didn't work because there were spaces in my directory path. Mar 23, 2018 at 14:11
  • I used this to convert PDF to SVG using pdf2svg. Excellent answer!
    – MycrofD
    May 5, 2019 at 21:07
  • Tested on Ubuntu 16.04. Great! Feb 25, 2020 at 19:47
6

Some other options tools to convert to/from SVG from the Inkscape Wiki:

1
  • 1
    I started using ConversionSVG. Amazing, It was lightweight. No pretence, just what I was looking for. Thanks a lot Jun 21, 2012 at 18:19
3

You can do this using Inkscape's command line interface (inkscape --without-gui --export-pdf=myfile.pdf myfile.svg), and then use a batch file, shell script, or build tool (such as Make, Rake, or Grunt) to run that automatically on a whole list of files.

3

After looking multiple sites I've found a simple way using only one command line.

I've never used command line before, but after some experimentation i've came with the following solution:

for /f "tokens=1* delims=." %i in ('dir /b *.svg') do "C:\Program Files\Inkscape\inkscape.exe" --without-gui --file="%i.svg" --export-emf="%i.emf"

Breaking it down:

for

for is a command to perform an action to multiple files. It's structure is something like: for "files in a certain condition" do "especific command"

/f "tokens=1* delims=." %i in ('dir /b *.svg')

This is the "condition". In my case, I'm looking for all SVG files, but of course it works with others formats. All this "fancy" code does is store the file name, before the extention, in the variable "%i". This will be usefull in the comand.

do

That is what you will perform in all the files.

"C:\Program Files\Inkscape\inkscape.exe" --without-gui --file="%i.svg" --export-emf="%i.emf"

This is the same command Marnen Laibow-Koser used above. I'm a newbie, i don't know how you use just "inkscape", so i've putted all the way to the .exe.

The last part is where we use the variable to instruct the program to wich file it should pick and how export.

Again, I'm exporting SVG to EMF, but just change it to what you want. Here is why the variable are so important. So you can keep the same name, just changing the extention.

Don't forget to use the quotes, since your files can have some space in it's name.

Of course you also need to be in the folder where your files are. If your are also a newbie do this:

C:\

It will put you in the correct drive.

CD "path"

It will take you to the specific folder. You can use the windows explorer and click with right button and copy the path as text.

That's it. I'm newbie, soo it might be someway more efective to do it, but this will work.

Last tip: If you are working with a lot of files, you can use CTRL + C to stop the command line if it's not working how it should, and try again.

0

This link seems to have what you want: Batch export from inkscape in windows.

1
  • The link is unfortunately dead, and it seems like InkscapeBatch was abandoned.
    – andselisk
    Sep 21, 2017 at 8:26
0

Assuming you have consecutive file names.

Assuming you are using macOS.

INDIR='3. SVGs/svgs-front'
OUTDIR='4. Individual PDFs/pdfs-front'
seq 1 100 | while read row; do
  echo Processing $row
  /Applications/Inkscape.app/Contents/MacOS/inkscape -o $OUTDIR/$row.pdf --without-gui $INDIR/$row.svg 
done
-2

For me the best way to do it is zamzar.com which is a free online file conversion site. It allows user to convert files without downloading a software tool, and supports over 1,000 different conversion types.

1
  • Hello user17598, welcome to GDSE and thank you for your contribution. Could you please tell us a bit more about what we can find at your link? We'd like your post to be useful to future visitors, even in the case your link breaks. Thanks and enjoy your stay!
    – Vincent
    Nov 15, 2013 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.