Skip to content

Instantly share code, notes, and snippets.

@foreachthing
Forked from JohannesDeml/README.md
Last active August 30, 2021 19:41
Show Gist options
  • Save foreachthing/ad1da9b22f77b31cc6be844b2b25db16 to your computer and use it in GitHub Desktop.
Save foreachthing/ad1da9b22f77b31cc6be844b2b25db16 to your computer and use it in GitHub Desktop.
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

Version:

  • Added svg to output types. You can now convert pdf2svg.
@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
set validOutput4=svg
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%, %validOutput4%
: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 "%outputType%" EQU "%validOutput4%" set valid=1
if %valid% EQU 0 (
echo Invalid input! Please use one of the following: %validOutput1%, %validOutput2%, %validOutput3%, %validOutput4%
goto :whileOutNotCorrect
)
:: If outputType = svg, then set outputType to "plain-svg" and thisext to svg
set "thisext=%outputType%"
if "%outputType%" EQU "%validOutput4%" (
set outputType=plain-svg
set thisext=svg
)
:: 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.%thisext%
"%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~ni.%thisext%" --export-dpi=%dpi%
)
echo %count% file(s) converted from %sourceType% to %thisext%!
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment