Skip to content

Instantly share code, notes, and snippets.

@rokdd
Forked from JohannesDeml/README.md
Last active February 14, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rokdd/a727962c3bc3fc7cce702c8af5c03980 to your computer and use it in GitHub Desktop.
Save rokdd/a727962c3bc3fc7cce702c8af5c03980 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|svg

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
set validOutput4=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%, %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%
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%
if "%outputType%" EQU "%validOutput4%" (
"%inkscapePath%" --without-gui --file="%%i" --export-plain-%outputType%="%%~ni.%outputType%" --export-dpi=%dpi%
) else (
"%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~ni.%outputType%" --export-dpi=%dpi%
)
)
echo %count% file(s) converted from %sourceType% to %outputType%!
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment