Skip to content

Instantly share code, notes, and snippets.

@loganpowell
Last active November 5, 2022 19:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loganpowell/5ba8232145081cde94d65f20ee6cb0f1 to your computer and use it in GitHub Desktop.
Save loganpowell/5ba8232145081cde94d65f20ee6cb0f1 to your computer and use it in GitHub Desktop.
batch process all svg files in containing folder with scour (Windows `.bat` file)
@Echo off
setlocal ENABLEDELAYEDEXPANSION
echo.
echo This script runs through all the .svg files in the folder within which this file is contained and outputs an optimized version to the 'out' folder here...
:: echo (type q to quit at any question)
echo.
:: count how many files we need to convert before converting!
set /a total=0
for /R %%i in (*.svg) do (
if not exist %%~di%%~piout mkdir %%~di%%~piout
set /a total=total+1
)
echo Conversion started. Will do %total% file(s).
echo.
for /R %%i in (*.svg) do (
set /a count=count+1
echo.
echo %%i -^> %%~di%%~piout\%%~ni.%outputType% ^[!count!/%total%^]
echo %%~ni
echo.
:: requires python package: https://github.com/scour-project/scour
scour -i %%~ni.svg -o %%~di%%~piout\%%~ni.svg --enable-viewboxing --enable-id-stripping --enable-comment-stripping --shorten-ids --indent=none
)
@loganpowell
Copy link
Author

used for reducing the file size of layers exported from Inkscape's File > Save As > Layers as Separate SVG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment