Skip to content

Instantly share code, notes, and snippets.

@thecocce
Forked from JohannesDeml/README.md
Created February 26, 2025 17:00
Show Gist options
  • Save thecocce/aa5dfbe43bb238c55b5f0e8f1b6b7cc8 to your computer and use it in GitHub Desktop.
Save thecocce/aa5dfbe43bb238c55b5f0e8f1b6b7cc8 to your computer and use it in GitHub Desktop.

Revisions

  1. @JohannesDeml JohannesDeml revised this gist Nov 12, 2023. No changes.
  2. @JohannesDeml JohannesDeml revised this gist Nov 12, 2023. 2 changed files with 9 additions and 43 deletions.
    12 changes: 7 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    ## Batch convert svg|pdf|eps|emf|wmf|ai|ps to eps|pdf|png|svg|ps|emf|wmf
    ## Batch convert svg|pdf|eps|emf|wmf|ai|ps|cdr to eps|pdf|png|jpg|tiff|svg|ps|emf|wmf
    ![Screenshot](https://i.imgur.com/tmN6zXe.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    Tested with Inkscape 0.9.x - 1.3.x ✅
    Tested with Inkscape 1.0.x - 1.3.x ✅ (The last version that supports Inkscape 0.9.x can be found [here](https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11/a8a66794eddede521053c9242eca10239110cc1f))

    ## Usage
    1. Download `_InkscapeBatchConvert.bat`
    2. Put it in the folder where you have files you wish to convert.
    2. Put it in the folder where you have files you wish to convert (will also scan on all subfolders for files of input type).
    3. Then double click the file to start it.

    ## Troubleshooting
    @@ -18,11 +18,13 @@ Tested with Inkscape 0.9.x - 1.3.x ✅
    | I can't convert EPS / PDF files. The program says it runs the conversion, but there are no files in the out folder. | Make sure you have ghost script installed and added to your environment path. For more information read the [Inkscape FAQ](https://inkscape.org/learn/faq/#how-open-eps-files-windows) |
    | | ![Add ghostscript to path](https://i.imgur.com/aw59Zis.png) |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by adding the next array element of `inkscapePaths` to the script |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/z2RreHx.png) |
    | I'm missing a setting in the script, e.g. defined output width | Have a look at the [Commandline Documentation](https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line) or read the inkscape help file `inkscape --help` and add the needed properties to the script |
    | ![Inkscape help output](https://i.imgur.com/PHublJx.png) | ![Script change position](https://i.imgur.com/fNeaz8j.png) |
    | I'm missing a specific input or output type | If inkscape supports those types, you can easily add them to the list in the script (search for `validInput` and `validOutput`) |
    | | ![Add input / output type](https://i.imgur.com/yE0kIaH.png) |
    | | ![Add input / output type](https://i.imgur.com/h3ZA8oj.png) |
    | The files are saved to `out\`, but I would like to have it saved in the same directory or a subdirectory with a different name | Just change the variable `relativeOutputFolder` - If you want to save the files to the same directory, set it to nothing (`set relativeOutputFolder=`) |
    | | ![Set subdirectory](https://i.imgur.com/JpIh0ZN.png) |

    ## Todo

    40 changes: 2 additions & 38 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    :: From https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11
    :: Convert vector file formats in the current folder and their subsfolders
    :: The variables in the beginning can be changed to your needs
    :: Tested for Inkscape 1.0 - 1.3

    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    @@ -119,25 +121,6 @@ if "%outputType%" EQU "%sourceType%" (

    echo.

    :: Older inkscape versions need to generate a pdf before generating svgs
    if %inkscapeMajorVersion% EQU 0 (
    set toDelOrNot=n
    if "%sourceType%" NEQ "pdf" (
    if "%outputType%" EQU "%validOutput4%" (
    set valid=0
    :whilePdfDelNotCorrect
    set /p toDelOrNot=EPS to SVG also generates pdfs, delete these after conversion? (y/n^)
    if "%toDelOrNot%" EQU "y" set valid=1
    if "%toDelOrNot%" EQU "n" set valid=1
    if "%toDelOrNot%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please type either y or n.
    goto :whilePdfDelNotCorrect
    )
    )
    )
    )

    :: Set DPI for exported file
    :whileNotValidDpiNumber
    set /p dpi=With what dpi should it be exported (e.g. 300)?
    @@ -170,25 +153,6 @@ if %inkscapeMajorVersion% NEQ 0 (
    echo %%i -^> %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType% ^[!count!/%total%^]
    %inkscapePath% --export-filename="%%~di%%~pi!relativeOutputFolder!%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    )
    ) else (
    :: Inkscape 0.9.x and older
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%=" %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType%" --export-dpi=%dpi%
    ) else (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --without-gui --file="%%i" --export-pdf=" %%~di%%~pi!relativeOutputFolder!%%~ni.pdf" --export-dpi=%dpi%
    )
    %inkscapePath% --without-gui -z -f "%%~di%%~pi!relativeOutputFolder!%%~ni.pdf" -l "%%~di%%~pi!relativeOutputFolder!%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    )
    )

    echo.
  3. @JohannesDeml JohannesDeml revised this gist Nov 12, 2023. 1 changed file with 17 additions and 14 deletions.
    31 changes: 17 additions & 14 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,16 @@
    @echo off
    setlocal ENABLEDELAYEDEXPANSION

    :: Define supported input file extensions
    set validInput=svg pdf eps emf wmf ps ai cdr

    :: Define supported output file extensions
    :: All supported extnesions: [.dxf, .emf, .eps, .fxg, .gpl, .hpgl, .html, .jpg, .odg, .pdf, .png, .pov, .ps, .sif, .svg, .svgz, .tar, .tex, .tiff, .webp, .wmf, .xaml, .zip]
    set validOutput=svg png tiff jpg webp pdf eps emf wmf ps cdr

    :: Define relative output folder, if you want to write to the same folder set the var to an empty string
    set relativeOutputFolder=out\

    :: Possible paths to check for the installation
    set "inkscapePaths[1]=C:\Program Files\Inkscape\bin\inkscape.com"
    set "inkscapePaths[2]=C:\Program Files\Inkscape\bin\inkscape.exe"
    @@ -13,9 +23,6 @@ set "inkscapePaths[5]=C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
    set "inkscapePaths[6]=C:\Program Files (x86)\Inkscape\inkscape.com"
    set "inkscapePaths[7]=%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"

    :: Define relative output folder, if you want to write to the same folder set the var to . (remove \out)
    set relativeOutputFolder=.\out

    set "inkscapePath="
    set /a "pathIndex=1"

    @@ -39,17 +46,13 @@ if defined inkscapePaths[%pathIndex%] (
    :: Set the path to allow for spaces without any needed additional quotes
    set inkscapePath="%inkscapePath%"

    :: Define supported input file extensions
    set validInput=svg pdf eps emf wmf ps ai
    set validInputString=
    (for %%a in (%validInput%) do (
    set validInputString=!validInputString!, %%a
    ))
    :: Remove the leading comma
    set validInputString=%validInputString:~2%

    :: Define supported output file extensions
    set validOutput=svg png pdf eps emf wmf ps
    set validOutputString=
    (for %%a in (%validOutput%) do (
    set validOutputString=!validOutputString!, %%a
    @@ -153,7 +156,7 @@ echo Found %total% file(s) of type *.%sourceType% in the current folder (%~dp0)
    echo.

    :: Create output folder if it is set and does not exist
    if not "!relativeOutputFolder!"=="." (
    if not "!relativeOutputFolder!"=="" (
    if not exist "!relativeOutputFolder!" mkdir "!relativeOutputFolder!"
    )

    @@ -164,23 +167,23 @@ if %inkscapeMajorVersion% NEQ 0 (
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> !relativeOutputFolder!\%%~ni.%outputType% ^[!count!/%total%^]
    %inkscapePath% --export-filename="!relativeOutputFolder!\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    echo %%i -^> %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType% ^[!count!/%total%^]
    %inkscapePath% --export-filename="%%~di%%~pi!relativeOutputFolder!%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    )
    ) else (
    :: Inkscape 0.9.x and older
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> !relativeOutputFolder!\%%~ni.%outputType% ^[!count!/%total%^]
    echo %%i -^> %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%="!relativeOutputFolder!\%%~ni.%outputType%" --export-dpi=%dpi%
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%=" %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType%" --export-dpi=%dpi%
    ) else (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --without-gui --file="%%i" --export-pdf="!relativeOutputFolder!\%%~ni.pdf" --export-dpi=%dpi%
    %inkscapePath% --without-gui --file="%%i" --export-pdf=" %%~di%%~pi!relativeOutputFolder!%%~ni.pdf" --export-dpi=%dpi%
    )
    %inkscapePath% --without-gui -z -f "out\%%~ni.pdf" -l "!relativeOutputFolder!\%%~ni.%validOutput4%"
    %inkscapePath% --without-gui -z -f "%%~di%%~pi!relativeOutputFolder!%%~ni.pdf" -l "%%~di%%~pi!relativeOutputFolder!%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
  4. @JohannesDeml JohannesDeml revised this gist Nov 11, 2023. 1 changed file with 15 additions and 14 deletions.
    29 changes: 15 additions & 14 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,9 @@ set "inkscapePaths[5]=C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
    set "inkscapePaths[6]=C:\Program Files (x86)\Inkscape\inkscape.com"
    set "inkscapePaths[7]=%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"

    :: Define relative output folder, if you want to write to the same folder set the var to . (remove \out)
    set relativeOutputFolder=.\out

    set "inkscapePath="
    set /a "pathIndex=1"

    @@ -149,37 +152,35 @@ echo Found %total% file(s) of type *.%sourceType% in the current folder (%~dp0)

    echo.

    :: Create output folder if it is set and does not exist
    if not "!relativeOutputFolder!"=="." (
    if not exist "!relativeOutputFolder!" mkdir "!relativeOutputFolder!"
    )

    set /a count=0
    :: Running through all files found with the defined ending
    if %inkscapeMajorVersion% NEQ 0 (
    :: Inkscape 1.0 and newer
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    :: Create out folder if it does not exist
    if not exist "%%~di%%~piout" mkdir "%%~di%%~piout"

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"

    echo %%i -^> !relativeOutputFolder!\%%~ni.%outputType% ^[!count!/%total%^]
    %inkscapePath% --export-filename="!relativeOutputFolder!\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    )
    ) else (
    :: Inkscape 0.9.x and older
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    :: Create out folder if it does not exist
    if not exist "%%~di%%~piout" mkdir "%%~di%%~piout"

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]
    echo %%i -^> !relativeOutputFolder!\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi%
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%="!relativeOutputFolder!\%%~ni.%outputType%" --export-dpi=%dpi%
    ) else (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --without-gui --file="%%i" --export-pdf="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi%
    %inkscapePath% --without-gui --file="%%i" --export-pdf="!relativeOutputFolder!\%%~ni.pdf" --export-dpi=%dpi%
    )
    %inkscapePath% --without-gui -z -f "out\%%~ni.pdf" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    %inkscapePath% --without-gui -z -f "out\%%~ni.pdf" -l "!relativeOutputFolder!\%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
  5. @JohannesDeml JohannesDeml revised this gist Jul 31, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    ![Screenshot](https://i.imgur.com/tmN6zXe.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    Tested with Inkscape 0.9.x - 1.2.x ✅
    Tested with Inkscape 0.9.x - 1.3.x ✅

    ## Usage
    1. Download `_InkscapeBatchConvert.bat`
    @@ -17,7 +17,7 @@ Tested with Inkscape 0.9.x - 1.2.x ✅
    | ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png) | ![Disable blocking](https://i.imgur.com/2SBAyuv.png) |
    | I can't convert EPS / PDF files. The program says it runs the conversion, but there are no files in the out folder. | Make sure you have ghost script installed and added to your environment path. For more information read the [Inkscape FAQ](https://inkscape.org/learn/faq/#how-open-eps-files-windows) |
    | | ![Add ghostscript to path](https://i.imgur.com/aw59Zis.png) |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by setting `inkscapePath1` yourself |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by adding the next array element of `inkscapePaths` to the script |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |
    | I'm missing a setting in the script, e.g. defined output width | Have a look at the [Commandline Documentation](https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line) or read the inkscape help file `inkscape --help` and add the needed properties to the script |
    | ![Inkscape help output](https://i.imgur.com/PHublJx.png) | ![Script change position](https://i.imgur.com/fNeaz8j.png) |
  6. @JohannesDeml JohannesDeml revised this gist Jul 31, 2023. 1 changed file with 29 additions and 28 deletions.
    57 changes: 29 additions & 28 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -1,39 +1,40 @@
    :: From https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11
    :: Convert vector file formats in the current folder and their subsfolders

    @Echo off
    @echo off
    setlocal ENABLEDELAYEDEXPANSION

    :: Possible paths to check for the installation
    set inkscapePath1="C:\Program Files\Inkscape\bin\inkscape.com"
    set inkscapePath2="C:\Program Files\Inkscape\inkscape.com"
    set inkscapePath3="C:\Program Files (x86)\Inkscape\bin\inkscape.com"
    set inkscapePath4="C:\Program Files (x86)\Inkscape\inkscape.com"
    set inkscapePath5="%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"


    if exist %inkscapePath1% (
    set inkscapePath=%inkscapePath1%
    ) else (
    if exist %inkscapePath2% (
    set inkscapePath=%inkscapePath2%
    ) else (
    if exist %inkscapePath3% (
    set inkscapePath=%inkscapePath3%
    ) else (
    if exist %inkscapePath4% (
    set inkscapePath=%inkscapePath4%
    ) else (
    if exist %inkscapePath5% (
    set inkscapePath=%inkscapePath5%
    ) else (
    echo Can't find Inkscape installation, aborting.
    GOTO end
    )
    )
    )
    set "inkscapePaths[1]=C:\Program Files\Inkscape\bin\inkscape.com"
    set "inkscapePaths[2]=C:\Program Files\Inkscape\bin\inkscape.exe"
    set "inkscapePaths[3]=C:\Program Files\Inkscape\inkscape.com"
    set "inkscapePaths[4]=C:\Program Files (x86)\Inkscape\bin\inkscape.com"
    set "inkscapePaths[5]=C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
    set "inkscapePaths[6]=C:\Program Files (x86)\Inkscape\inkscape.com"
    set "inkscapePaths[7]=%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"

    set "inkscapePath="
    set /a "pathIndex=1"

    :: Find the inkscape installation path
    :inkscapepath_loop_start
    if defined inkscapePaths[%pathIndex%] (
    set "currentPath=!inkscapePaths[%pathIndex%]!"
    if exist "!currentPath!" (
    :: found installation path
    set "inkscapePath=!currentPath!"
    goto :inkscapepath_loop_end
    )
    set /a "pathIndex+=1"
    goto :inkscapepath_loop_start
    ) else (
    echo Can't find Inkscape installation, aborting.
    goto end
    )
    :inkscapepath_loop_end

    :: Set the path to allow for spaces without any needed additional quotes
    set inkscapePath="%inkscapePath%"

    :: Define supported input file extensions
    set validInput=svg pdf eps emf wmf ps ai
  7. @JohannesDeml JohannesDeml revised this gist Feb 21, 2023. 2 changed files with 41 additions and 28 deletions.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Batch convert svg|pdf|eps|emf|wmf to eps|pdf|png|svg
    ## Batch convert svg|pdf|eps|emf|wmf|ai|ps to eps|pdf|png|svg|ps|emf|wmf
    ![Screenshot](https://i.imgur.com/tmN6zXe.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    @@ -21,6 +21,8 @@ Tested with Inkscape 0.9.x - 1.2.x ✅
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |
    | I'm missing a setting in the script, e.g. defined output width | Have a look at the [Commandline Documentation](https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line) or read the inkscape help file `inkscape --help` and add the needed properties to the script |
    | ![Inkscape help output](https://i.imgur.com/PHublJx.png) | ![Script change position](https://i.imgur.com/fNeaz8j.png) |
    | I'm missing a specific input or output type | If inkscape supports those types, you can easily add them to the list in the script (search for `validInput` and `validOutput`) |
    | | ![Add input / output type](https://i.imgur.com/yE0kIaH.png) |

    ## Todo

    65 changes: 38 additions & 27 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -35,17 +35,23 @@ if exist %inkscapePath1% (
    )
    )


    set validInput1=svg
    set validInput2=pdf
    set validInput3=eps
    set validInput4=emf
    set validInput5=wmf

    set validOutput1=eps
    set validOutput2=pdf
    set validOutput3=png
    set validOutput4=svg
    :: Define supported input file extensions
    set validInput=svg pdf eps emf wmf ps ai
    set validInputString=
    (for %%a in (%validInput%) do (
    set validInputString=!validInputString!, %%a
    ))
    :: Remove the leading comma
    set validInputString=%validInputString:~2%

    :: Define supported output file extensions
    set validOutput=svg png pdf eps emf wmf ps
    set validOutputString=
    (for %%a in (%validOutput%) do (
    set validOutputString=!validOutputString!, %%a
    ))
    :: Remove the leading comma
    set validOutputString=%validOutputString:~2%

    :: If this can't be run, then the version is an older one
    FOR /F "tokens=* USEBACKQ" %%g IN (`%inkscapePath% --version`) do (SET "inkscapeVersion=%%g")
    @@ -63,37 +69,42 @@ echo (type q to quit at any question)
    echo.

    set valid=0
    echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%

    echo Allowed file types for source: %validInputString%
    :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 "%sourceType%" EQU "%validInput4%" set valid=1
    if "%sourceType%" EQU "%validInput5%" set valid=1
    set /p sourceType=What file type do you want to use as a source?
    if "%sourceType%" EQU "q" exit /b
    for %%a in (%validInput%) do (
    if "%%a"=="%sourceType%" (
    set valid=1
    goto inSet
    )
    )
    if %valid% EQU 0 (
    echo Invalid input! Please use one of the following: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%
    echo Invalid input! Please use one of the following: %validInputString%
    goto :whileInNotCorrect
    )


    :inSet
    echo.

    set valid=0
    echo Allowed file types for output: %validOutput1%, %validOutput2%, %validOutput3%, %validOutput4%
    echo Allowed file types for output: %validOutputString%
    :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 "%outputType%" EQU "q" exit /b
    for %%a in (%validOutput%) do (
    if "%%a"=="%outputType%" (
    set valid=1
    goto outSet
    )
    )
    if %valid% EQU 0 (
    echo Invalid input! Please use one of the following: %validOutput1%, %validOutput2%, %validOutput3%, %validOutput4%
    echo Invalid input! Please use one of the following: %validOutputString%
    goto :whileOutNotCorrect
    )

    :outSet

    if "%outputType%" EQU "%sourceType%" (
    echo Input and Output are the same, no point in doing anything. Exiting...
    exit /b
  8. @JohannesDeml JohannesDeml revised this gist Jan 6, 2023. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ set inkscapePath1="C:\Program Files\Inkscape\bin\inkscape.com"
    set inkscapePath2="C:\Program Files\Inkscape\inkscape.com"
    set inkscapePath3="C:\Program Files (x86)\Inkscape\bin\inkscape.com"
    set inkscapePath4="C:\Program Files (x86)\Inkscape\inkscape.com"
    set inkscapePath5="%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"


    if exist %inkscapePath1% (
    @@ -23,8 +24,12 @@ if exist %inkscapePath1% (
    if exist %inkscapePath4% (
    set inkscapePath=%inkscapePath4%
    ) else (
    echo Can't find Inkscape installation, aborting.
    GOTO end
    if exist %inkscapePath5% (
    set inkscapePath=%inkscapePath5%
    ) else (
    echo Can't find Inkscape installation, aborting.
    GOTO end
    )
    )
    )
    )
  9. @JohannesDeml JohannesDeml revised this gist Nov 16, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    ![Screenshot](https://i.imgur.com/tmN6zXe.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    Tested with Inkscape 0.9.x - 1.0.x ✅
    Tested with Inkscape 0.9.x - 1.2.x ✅

    ## Usage
    1. Download `_InkscapeBatchConvert.bat`
  10. @JohannesDeml JohannesDeml revised this gist Jul 21, 2022. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -127,10 +127,8 @@ echo.

    :: count how many files we need to convert before converting!
    set /a total=0
    for /R %%i in (*.%sourceType%) do (
    set /a total=total+1
    )
    echo Conversion started. Will do %total% file(s).
    for /R %%i in (*.%sourceType%) do ( set /a total=total+1 )
    echo Found %total% file(s) of type *.%sourceType% in the current folder (%~dp0)

    echo.

  11. @JohannesDeml JohannesDeml revised this gist Aug 28, 2021. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    :: From https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11
    :: Convert vector file formats in the current folder and their subsfolders

    @Echo off
    setlocal ENABLEDELAYEDEXPANSION

    @@ -39,12 +42,18 @@ set validOutput2=pdf
    set validOutput3=png
    set validOutput4=svg

    :: If this can't be run, then the version is an older one
    FOR /F "tokens=* USEBACKQ" %%g IN (`%inkscapePath% --version`) do (SET "inkscapeVersion=%%g")
    if "%inkscapeVersion%" EQU "" (
    set inkscapeVersion=0.x
    set /a inkscapeMajorVersion=0
    ) else (
    set /a inkscapeMajorVersion=%inkscapeVersion:~9,1%
    )

    echo.
    echo This script allows you to convert all files in this folder from one file type to another
    echo Running with %inkscapeVersion%
    echo Running with %inkscapeVersion% from %inkscapePath%
    echo (type q to quit at any question)
    echo.

  12. @JohannesDeml JohannesDeml revised this gist May 11, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -133,7 +133,7 @@ if %inkscapeMajorVersion% NEQ 0 (
    set /a count=count+1

    :: Create out folder if it does not exist
    if not exist %%~di%%~piout mkdir %%~di%%~piout
    if not exist "%%~di%%~piout" mkdir "%%~di%%~piout"

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    @@ -144,6 +144,9 @@ if %inkscapeMajorVersion% NEQ 0 (
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    :: Create out folder if it does not exist
    if not exist "%%~di%%~piout" mkdir "%%~di%%~piout"

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
  13. @JohannesDeml JohannesDeml revised this gist Apr 28, 2021. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@
    setlocal ENABLEDELAYEDEXPANSION

    :: Possible paths to check for the installation
    set inkscapePath1="C:\Program Files\Inkscape\bin\inkscape.exe"
    set inkscapePath2="C:\Program Files\Inkscape\inkscape.exe"
    set inkscapePath3="C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
    set inkscapePath4="C:\Program Files (x86)\Inkscape\inkscape.exe"
    set inkscapePath1="C:\Program Files\Inkscape\bin\inkscape.com"
    set inkscapePath2="C:\Program Files\Inkscape\inkscape.com"
    set inkscapePath3="C:\Program Files (x86)\Inkscape\bin\inkscape.com"
    set inkscapePath4="C:\Program Files (x86)\Inkscape\inkscape.com"


    if exist %inkscapePath1% (
    @@ -137,7 +137,7 @@ if %inkscapeMajorVersion% NEQ 0 (

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    )
    ) else (
    :: Inkscape 0.9.x and older
  14. @JohannesDeml JohannesDeml revised this gist Dec 16, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,8 @@ Tested with Inkscape 0.9.x - 1.0.x ✅
    | ------------------------------------------------------------ | ------------------------------------------------------------ |
    | Windows blocks the program | `Right click the file → Properties → Unblock` |
    | ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png) | ![Disable blocking](https://i.imgur.com/2SBAyuv.png) |
    | I can't convert EPS / PDF files. The program says it runs the conversion, but there are no files in the out folder. | Make sure you have ghost script installed and added to your environment path. For more information read the [Inkscape FAQ](https://inkscape.org/learn/faq/#how-open-eps-files-windows) |
    | | ![Add ghostscript to path](https://i.imgur.com/aw59Zis.png) |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by setting `inkscapePath1` yourself |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |
    | I'm missing a setting in the script, e.g. defined output width | Have a look at the [Commandline Documentation](https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line) or read the inkscape help file `inkscape --help` and add the needed properties to the script |
  15. @JohannesDeml JohannesDeml revised this gist Dec 9, 2020. 1 changed file with 17 additions and 25 deletions.
    42 changes: 17 additions & 25 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -87,19 +87,22 @@ if "%outputType%" EQU "%sourceType%" (

    echo.

    set toDelOrNot=n
    if "%sourceType%" NEQ "pdf" (
    if "%outputType%" EQU "%validOutput4%" (
    set valid=0
    :whilePdfDelNotCorrect
    set /p toDelOrNot=EPS to SVG also generates pdfs, delete these after conversion? (y/n^)
    if "%toDelOrNot%" EQU "y" set valid=1
    if "%toDelOrNot%" EQU "n" set valid=1
    if "%toDelOrNot%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please type either y or n.
    goto :whilePdfDelNotCorrect
    )
    :: Older inkscape versions need to generate a pdf before generating svgs
    if %inkscapeMajorVersion% EQU 0 (
    set toDelOrNot=n
    if "%sourceType%" NEQ "pdf" (
    if "%outputType%" EQU "%validOutput4%" (
    set valid=0
    :whilePdfDelNotCorrect
    set /p toDelOrNot=EPS to SVG also generates pdfs, delete these after conversion? (y/n^)
    if "%toDelOrNot%" EQU "y" set valid=1
    if "%toDelOrNot%" EQU "n" set valid=1
    if "%toDelOrNot%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please type either y or n.
    goto :whilePdfDelNotCorrect
    )
    )
    )
    )

    @@ -132,20 +135,9 @@ if %inkscapeMajorVersion% NEQ 0 (
    :: Create out folder if it does not exist
    if not exist %%~di%%~piout mkdir %%~di%%~piout


    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    ) else (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    )
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    )
    ) else (
    :: Inkscape 0.9.x and older
  16. @JohannesDeml JohannesDeml revised this gist May 17, 2020. 2 changed files with 10 additions and 3 deletions.
    7 changes: 7 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,15 @@ Tested with Inkscape 0.9.x - 1.0.x ✅
    | ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png) | ![Disable blocking](https://i.imgur.com/2SBAyuv.png) |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by setting `inkscapePath1` yourself |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |
    | I'm missing a setting in the script, e.g. defined output width | Have a look at the [Commandline Documentation](https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line) or read the inkscape help file `inkscape --help` and add the needed properties to the script |
    | ![Inkscape help output](https://i.imgur.com/PHublJx.png) | ![Script change position](https://i.imgur.com/fNeaz8j.png) |

    ## Todo

    Use shell or pipe to avoid starting inkscape for every file as pointed out by @vaifrax [here](https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11#gistcomment-2697671). I would be very happy to get help for that 🙂

    ## Credits

    * [JohannesDeml](https://github.com/JohannesDeml)
    * [Elrinth](https://github.com/Elrinth)
    * [leifcr](https://github.com/leifcr)
    6 changes: 3 additions & 3 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -136,12 +136,12 @@ if %inkscapeMajorVersion% NEQ 0 (
    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    ) else (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    )
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    %inkscapePath% --batch-process --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
  17. @JohannesDeml JohannesDeml revised this gist May 16, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -122,14 +122,17 @@ echo Conversion started. Will do %total% file(s).

    echo.


    set /a count=0
    :: Running through all files found with the defined ending
    if %inkscapeMajorVersion% NEQ 0 (
    :: Inkscape 1.0 and newer
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    :: Create out folder if it does not exist
    if not exist %%~di%%~piout mkdir %%~di%%~piout


    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
  18. @JohannesDeml JohannesDeml revised this gist May 15, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -157,7 +157,7 @@ if %inkscapeMajorVersion% NEQ 0 (
    if "%sourceType%" NEQ "pdf" (
    %inkscapePath% --without-gui --file="%%i" --export-pdf="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi%
    )
    %inkscapePath% --without-gui -z -f "%%i" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    %inkscapePath% --without-gui -z -f "out\%%~ni.pdf" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
  19. @JohannesDeml JohannesDeml revised this gist May 15, 2020. 2 changed files with 45 additions and 24 deletions.
    13 changes: 8 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Batch convert svg|pdf|eps|emf|wmf to eps|pdf|png|svg
    ![Screenshot](https://i.imgur.com/eCg8nVY.png)
    *Batch converter for Windows using Inkscape with the command line*
    ![Screenshot](https://i.imgur.com/tmN6zXe.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    Tested with Inkscape 0.9.x - 1.0.x ✅

    @@ -11,9 +11,12 @@ Tested with Inkscape 0.9.x - 1.0.x ✅

    ## Troubleshooting

    ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png)
    In order to enable running the program, right click the file->Properties->Unblock
    ![Disable blocking](https://i.imgur.com/2SBAyuv.png)
    | Problem | Solution |
    | ------------------------------------------------------------ | ------------------------------------------------------------ |
    | Windows blocks the program | `Right click the file → Properties → Unblock` |
    | ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png) | ![Disable blocking](https://i.imgur.com/2SBAyuv.png) |
    | Can't find Inkscape installation | All common file paths are checked for the installation. If you haven't installed Inkscape download it [here](https://inkscape.org/download), otherwise you can also define your own path in the script by setting `inkscapePath1` yourself |
    | ![Can't find inkscape installation](https://i.imgur.com/thIao2h.png) | ![custom inkscape path](https://i.imgur.com/ALZUBsl.png) |

    ## Credits
    * [JohannesDeml](https://github.com/JohannesDeml)
    56 changes: 37 additions & 19 deletions _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,30 @@
    @Echo off
    setlocal ENABLEDELAYEDEXPANSION

    if exist "C:\Program Files\Inkscape\bin\inkscape.exe" (
    set "inkscapePath=C:\Program Files\Inkscape\bin\inkscape.exe"
    :: Possible paths to check for the installation
    set inkscapePath1="C:\Program Files\Inkscape\bin\inkscape.exe"
    set inkscapePath2="C:\Program Files\Inkscape\inkscape.exe"
    set inkscapePath3="C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
    set inkscapePath4="C:\Program Files (x86)\Inkscape\inkscape.exe"


    if exist %inkscapePath1% (
    set inkscapePath=%inkscapePath1%
    ) else (
    set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
    if exist %inkscapePath2% (
    set inkscapePath=%inkscapePath2%
    ) else (
    if exist %inkscapePath3% (
    set inkscapePath=%inkscapePath3%
    ) else (
    if exist %inkscapePath4% (
    set inkscapePath=%inkscapePath4%
    ) else (
    echo Can't find Inkscape installation, aborting.
    GOTO end
    )
    )
    )
    )


    @@ -19,18 +39,15 @@ set validOutput2=pdf
    set validOutput3=png
    set validOutput4=svg

    FOR /F "tokens=* USEBACKQ" %%g IN (`"%inkscapePath%" --version`) do (SET "inkscapeVersion=%%g")
    FOR /F "tokens=* USEBACKQ" %%g IN (`%inkscapePath% --version`) do (SET "inkscapeVersion=%%g")
    set /a inkscapeMajorVersion=%inkscapeVersion:~9,1%

    echo.
    echo This script allows you to convert all files in this folder from one file type to another.
    echo This script allows you to convert all files in this folder from one file type to another
    echo Running with %inkscapeVersion%
    echo (type q to quit at any question)
    echo.

    set targetFolder=%%~d%%~p
    echo target folder: %targetFolder%

    set valid=0
    echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%

    @@ -108,39 +125,39 @@ echo.

    set /a count=0
    :: Running through all files found with the defined ending
    if %inkscapeMajorVersion% EQU 0 (
    :: Inkscape 0.9.x and older
    if %inkscapeMajorVersion% NEQ 0 (
    :: Inkscape 1.0 and newer
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi%
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    ) else (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --without-gui --file="%%i" --export-pdf="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi%
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    )
    "%inkscapePath%" --without-gui -z -f "%%i" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    %inkscapePath% --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    )
    ) else (
    :: Inkscape 1.0 and newer
    :: Inkscape 0.9.x and older
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    %inkscapePath% --without-gui --file="%%i" --export-%outputType%="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi%
    ) else (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    %inkscapePath% --without-gui --file="%%i" --export-pdf="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi%
    )
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    %inkscapePath% --without-gui -z -f "%%i" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    @@ -149,7 +166,8 @@ if %inkscapeMajorVersion% EQU 0 (
    )

    echo.
    echo %count% file(s) converted from %sourceType% to %outputType%!
    echo %count% file(s) converted from %sourceType% to %outputType%! (Saved in out folder)
    echo.


    :end
    pause
  20. @JohannesDeml JohannesDeml revised this gist May 15, 2020. 2 changed files with 67 additions and 26 deletions.
    19 changes: 13 additions & 6 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,19 @@
    ## Batch convert svg|pdf|eps|emf|wmf to eps|pdf|png|svg
    Batch converter for windows using InkScape and the command line
    Just download the file InkscapeBatchConvert.bat
    Put it in the folder where you have files you wish to convert.
    Then double click the file to start it.
    Tested with Inkscape 0.9.x - 1.0.x
    ![Screenshot](https://i.imgur.com/eCg8nVY.png)
    *Batch converter for Windows using Inkscape with the command line*
    InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
    Tested with Inkscape 0.9.x - 1.0.x ✅

    ## Usage
    1. Download `_InkscapeBatchConvert.bat`
    2. Put it in the folder where you have files you wish to convert.
    3. 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

    ![Windows protected your PC](https://i.imgur.com/fSAJXh0.png)
    In order to enable running the program, right click the file->Properties->Unblock
    ![Disable blocking](https://i.imgur.com/2SBAyuv.png)

    ## Credits
    * [JohannesDeml](https://github.com/JohannesDeml)
    74 changes: 54 additions & 20 deletions InkscapeBatchConvert.bat → _InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,12 @@
    @Echo off
    setlocal ENABLEDELAYEDEXPANSION

    if exist "C:\Program Files\Inkscape\bin\inkscape.exe" (
    set "inkscapePath=C:\Program Files\Inkscape\bin\inkscape.exe"
    ) else (
    set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
    )

    set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
    set /a count=0

    set validInput1=svg
    set validInput2=pdf
    @@ -14,11 +19,18 @@ set validOutput2=pdf
    set validOutput3=png
    set validOutput4=svg

    FOR /F "tokens=* USEBACKQ" %%g IN (`"%inkscapePath%" --version`) do (SET "inkscapeVersion=%%g")
    set /a inkscapeMajorVersion=%inkscapeVersion:~9,1%

    echo.
    echo This script allows you to convert all files in this folder from one file type to another.
    echo Running with %inkscapeVersion%
    echo (type q to quit at any question)
    echo.

    set targetFolder=%%~d%%~p
    echo target folder: %targetFolder%

    set valid=0
    echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%

    @@ -86,34 +98,56 @@ echo.

    :: count how many files we need to convert before converting!
    set /a total=0
    for /R %%i in (.\*.%sourceType%) do (
    for /R %%i in (*.%sourceType%) do (
    set /a total=total+1
    )
    echo Conversion started. Will do %total% file(s).

    echo.
    set /a curNr=1
    setlocal ENABLEDELAYEDEXPANSION


    set /a count=0
    :: Running through all files found with the defined ending
    for /R %%i in (.\*.%sourceType%) do (
    set /a count=count+1
    echo %%i -^> %%~pi%%~ni.%outputType% ^[!curNr!/%total%^]
    :: we didn't select svg:
    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~pi%%~ni.%outputType%" --export-dpi=%dpi%
    )
    :: for svg export first pdf, then svg...
    if "%outputType%" EQU "%validOutput4%" (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --without-gui --file="%%i" --export-pdf="%%~pi%%~ni.pdf" --export-dpi=%dpi%
    if %inkscapeMajorVersion% EQU 0 (
    :: Inkscape 0.9.x and older
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi%
    ) else (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --without-gui --file="%%i" --export-pdf="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi%
    )
    "%inkscapePath%" --without-gui -z -f "%%i" -l "%%~di%%~piout\%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    "%inkscapePath%" --without-gui -z -f "%%i" -l "%%~pi%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    ) else (
    :: Inkscape 1.0 and newer
    for /R %%i in (*.%sourceType%) do (
    set /a count=count+1

    echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]

    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
    ) else (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.pdf" --export-dpi=%dpi% "%%i"
    )
    "%inkscapePath%" --export-filename="%%~di%%~piout\%%~ni.svg" "%%~ni.pdf"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    )
    set /a curNr=curNr+1
    )

    echo.
    echo %count% file(s) converted from %sourceType% to %outputType%!
    echo.
  21. @JohannesDeml JohannesDeml revised this gist May 14, 2020. 2 changed files with 93 additions and 15 deletions.
    92 changes: 81 additions & 11 deletions InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -2,50 +2,120 @@

    set "inkscapePath=C:\Program Files\Inkscape\inkscape.exe"
    set /a count=0

    set validInput1=svg
    set validInput2=pdf
    set validInput3=eps
    set validInput4=emf
    set validInput5=wmf

    set validOutput1=eps
    set validOutput2=pdf
    set validOutput3=png
    set validOutput4=svg

    echo.
    echo This script allows you to convert all files in this folder from one file type to another.
    echo (type q to quit at any question)
    echo.

    set valid=0
    echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%
    echo Allowed file types for source: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%

    :whileInNotCorrect
    set /p sourceType=What file type do you want to use as a source?
    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 "%sourceType%" EQU "%validInput4%" set valid=1
    if "%sourceType%" EQU "%validInput5%" set valid=1
    if "%sourceType%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please use one of the following: %validInput1%, %validInput2%, %validInput3%
    echo Invalid input! Please use one of the following: %validInput1%, %validInput2%, %validInput3%, %validInput4%, %validInput5%
    goto :whileInNotCorrect
    )

    echo.

    set valid=0
    echo Allowed file types for output: %validOutput1%, %validOutput2%, %validOutput3%
    echo Allowed file types for output: %validOutput1%, %validOutput2%, %validOutput3%, %validOutput4%
    :whileOutNotCorrect
    set /p outputType=What file type do you want to convert to?
    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 "%outputType%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please use one of the following: %validOutput1%, %validOutput2%, %validOutput3%
    echo Invalid input! Please use one of the following: %validOutput1%, %validOutput2%, %validOutput3%, %validOutput4%
    goto :whileOutNotCorrect
    )

    if "%outputType%" EQU "%sourceType%" (
    echo Input and Output are the same, no point in doing anything. Exiting...
    exit /b
    )

    echo.

    set toDelOrNot=n
    if "%sourceType%" NEQ "pdf" (
    if "%outputType%" EQU "%validOutput4%" (
    set valid=0
    :whilePdfDelNotCorrect
    set /p toDelOrNot=EPS to SVG also generates pdfs, delete these after conversion? (y/n^)
    if "%toDelOrNot%" EQU "y" set valid=1
    if "%toDelOrNot%" EQU "n" set valid=1
    if "%toDelOrNot%" EQU "q" exit /b
    if %valid% EQU 0 (
    echo Invalid input! Please type either y or n.
    goto :whilePdfDelNotCorrect
    )
    )
    )

    :: Set DPI for exported file
    set /p dpi=With what dpi should it be exported (e.g. 300)?
    :whileNotValidDpiNumber
    set /p dpi=With what dpi should it be exported (e.g. 300)?
    if "%dpi%" EQU "q" exit /b
    IF %dpi% NEQ +%dpi% (
    echo Invalid input! Please input an actual number.
    goto :whilenotValidDpiNumber
    )
    echo.

    :: count how many files we need to convert before converting!
    set /a total=0
    for /R %%i in (.\*.%sourceType%) do (
    set /a total=total+1
    )
    echo Conversion started. Will do %total% file(s).

    echo.
    set /a curNr=1
    setlocal ENABLEDELAYEDEXPANSION
    :: Running through all files found with the defined ending
    for %%i in (.\*.%sourceType%) do (
    for /R %%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 %%i -^> %%~pi%%~ni.%outputType% ^[!curNr!/%total%^]
    :: we didn't select svg:
    if "%outputType%" NEQ "%validOutput4%" (
    "%inkscapePath%" --without-gui --file="%%i" --export-%outputType%="%%~pi%%~ni.%outputType%" --export-dpi=%dpi%
    )
    :: for svg export first pdf, then svg...
    if "%outputType%" EQU "%validOutput4%" (
    if "%sourceType%" NEQ "pdf" (
    "%inkscapePath%" --without-gui --file="%%i" --export-pdf="%%~pi%%~ni.pdf" --export-dpi=%dpi%
    )
    "%inkscapePath%" --without-gui -z -f "%%i" -l "%%~pi%%~ni.%validOutput4%"
    if "%toDelOrNot%" EQU "y" (
    del "%%~ni.pdf" /f /q
    )
    )
    set /a curNr=curNr+1
    )
    echo.
    echo %count% file(s) converted from %sourceType% to %outputType%!
    echo.

    pause
    16 changes: 12 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,14 @@
    ## 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.
    ## Batch convert svg|pdf|eps|emf|wmf to eps|pdf|png|svg
    Batch converter for windows using InkScape and the command line
    Just download the file InkscapeBatchConvert.bat
    Put it in the folder where you have files you wish to convert.
    Then double click the file to start it.
    Tested with Inkscape 0.9.x - 1.0.x

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

    ## Credits
    * [JohannesDeml](https://github.com/JohannesDeml)
    * [Elrinth](https://github.com/Elrinth)
    * [leifcr](https://github.com/leifcr)
  22. Johannes Deml revised this gist Mar 28, 2018. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    Batch converter for windows using inkscape and the command line

    Can convert file types svg, pdf and eps to eps, pdf and png.
    ## 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.
    If the program does not work, check what your instalation path of inkscape is. If the path is not C:\Program Files\Inkscape\inkscape.exe you need to change it at line 3 of the program.

    ## Troubleshooting
    Check if your inkscape path is C:\Program Files\Inkscape\inkscape.exe, otherwise change the path in line 3 in the bat script
  23. Johannes Deml created this gist Jan 23, 2018.
    51 changes: 51 additions & 0 deletions InkscapeBatchConvert.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    @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
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Batch converter for windows using inkscape and the command line

    Can convert file types svg, pdf and eps to eps, pdf and png.
    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.
    If the program does not work, check what your instalation path of inkscape is. If the path is not C:\Program Files\Inkscape\inkscape.exe you need to change it at line 3 of the program.