Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Batch converter for windows using inkscape and the command line

Batch convert svg|pdf|eps to eps|pdf|png

Batch converter for windows using inkscape and the command line
Just download the file InkscapeBatchConvert.bat and put it in the folder you want to run it at. Then double click the file to start it.

Troubleshooting

Check if your inkscape path is C:\Program Files\Inkscape\inkscape.exe, otherwise change the path in line 3 in the bat script

@Echo off
set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
set /a count=0
set validInput1=svg
set validInput2=pdf
set validInput3=eps
set validOutput1=eps
set validOutput2=pdf
set validOutput3=png
echo This script allows you to convert all files in this folder from one file type to another.
set valid=0
echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%
:whileInNotCorrect
set /p sourceType=What file type do you want to use as a source?
if "%sourceType%" EQU "%validInput1%" set valid=1
if "%sourceType%" EQU "%validInput2%" set valid=1
if "%sourceType%" EQU "%validInput3%" set valid=1
if %valid% EQU 0 (
echo Invalid input! Please use one of the following: %validInput1%, %validInput2%, %validInput3%
goto :whileInNotCorrect
)
set valid=0
echo Allowed file types for output: %validOutput1%, %validOutput2%, %validOutput3%
:whileOutNotCorrect
set /p outputType=What file type do you want to convert to?
if "%outputType%" EQU "%validOutput1%" set valid=1
if "%outputType%" EQU "%validOutput2%" set valid=1
if "%outputType%" EQU "%validOutput3%" set valid=1
if %valid% EQU 0 (
echo Invalid input! Please use one of the following: %validOutput1%, %validOutput2%, %validOutput3%
goto :whileOutNotCorrect
)
:: Set DPI for exported file
set /p dpi=With what dpi should it be exported (e.g. 300)?
:: Running through all files found with the defined ending
for %%i in (.\*.%sourceType%) do (
set /a count=count+1
echo %%i to %%~ni.%outputType%
"%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~ni.%outputType%" --export-dpi=%dpi%
)
echo %count% file(s) converted from %sourceType% to %outputType%!
pause
@myselfhimself

This comment has been minimized.

Copy link

myselfhimself commented Jul 11, 2018

Awesome!! Thank you for posting!! Would you know of a Unix (BA)SH version for that?

@myselfhimself

This comment has been minimized.

@absurdhart

This comment has been minimized.

Copy link

absurdhart commented Aug 20, 2018

@JohannesDeml I was wondering is there a way to modify this script so it looks in all subfolders as well?

@vaifrax

This comment has been minimized.

Copy link

vaifrax commented Sep 4, 2018

Thanks, this works but is slow.
There's also the --shell option. In a script you could either build a text file containing the commands and pass the file as the argument (inkscape --shell all-commands.txt) or you can pipe to inkscape. This avoids starting inkscape every time and greatly speeds up the whole process.

@sne11ius

This comment has been minimized.

Copy link

sne11ius commented Sep 24, 2018

Worked good for me. Thanks a lot!

@Gabrusp

This comment has been minimized.

Copy link

Gabrusp commented Oct 25, 2018

Thank you so much!!!

@Jacqvb

This comment has been minimized.

Copy link

Jacqvb commented Nov 14, 2018

Thanks! saved me a lot of time.

@foreachthing

This comment has been minimized.

Copy link

foreachthing commented Nov 17, 2018

Thanks! Very helpful!

@eric-chauveau

This comment has been minimized.

Copy link

eric-chauveau commented May 18, 2019

Many thanks^. Perfect!

@janncors

This comment has been minimized.

Copy link

janncors commented May 18, 2019

Thank you so much, awesome!!

@Elrinth

This comment has been minimized.

Copy link

Elrinth commented Jul 3, 2019

Thank you so much for this code!

I improved it to allow conversion directly from eps to svg. Also added some more information such as how many files it is before it starts, and that it is currently working on file x/total. Plus it has some more error handling. Check my fork.

I used it later to create a web font with https://glyphter.com/ . I simply drag 'n dropped all the svgs into glyphter and it created .css, .ttf, .eot, .svg, .woff . Glyphter is a bit buggy as some svgs weren't rendered correctly, plus not super intuitive, but I felt the results were better than FontForge.

@sskolpakchi

This comment has been minimized.

Copy link

sskolpakchi commented Sep 25, 2019

Thank you! Very usefull tool. It would be very nice if I could set the file mask for conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.