First you need to install imagemagick and svg2png
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
brew install imagemagick
brew install svg2png
Second, you need to run script, which creates multiple png and pack them into ico file.
cd your_folder_with_icons
FILES=*.svg
for f in $FILES
do
FULL_FILENAME=$f
FILENAME=${FULL_FILENAME##*/}
echo ${FILENAME%%.*}
svg2png $FULL_FILENAME ${FILENAME%%.*}"_256.png" -w 256
svg2png $FULL_FILENAME ${FILENAME%%.*}"_128.png" -w 128
svg2png $FULL_FILENAME ${FILENAME%%.*}"_64.png" -w 64
svg2png $FULL_FILENAME ${FILENAME%%.*}"_48.png" -w 48
svg2png $FULL_FILENAME ${FILENAME%%.*}"_32.png" -w 32
svg2png $FULL_FILENAME ${FILENAME%%.*}"_24.png" -w 24
svg2png $FULL_FILENAME ${FILENAME%%.*}"_16.png" -w 16
magick convert ${FILENAME%%.*}"_256.png" ${FILENAME%%.*}"_128.png" ${FILENAME%%.*}"_64.png" ${FILENAME%%.*}"_48.png" ${FILENAME%%.*}"_32.png" ${FILENAME%%.*}"_24.png" ${FILENAME%%.*}"_16.png" ${FILENAME%%.*}.ico
done
Profit!
Update for windows with Inkscape:
Install inkscape, install imagemagick, create folder with svg icons, create convert.bat in this folder, paste code, run convert.bat
@Echo off&SetLocal EnableDelayedExpansion
Set inkscape="C:\Program Files\Inkscape\bin\inkscape.com"
Set magick="C:\Program Files\ImageMagick-7.0.7-Q16\magick.exe"
Set "Pattern= "
Set "Replace=_"
For %%a in ("* *.svg") Do (
Set "File=%%~a"
Ren "%%a" "!File:%Pattern%=%Replace%!"
)
for %%f in (*.svg) do (
for %%r in (256 128 64 48 32 24 16) Do (
%inkscape% ^
--export-background-opacity=0 ^
--export-height=%%r ^
--export-type=png ^
--export-filename="%%~nf_%%rx%%r.png" ^
"%%~f"
)
mogrify -units "PixelsPerInch" -density 96 %%~nf_*.png
%magick% convert %%~nf_16x16.png ^
%%~nf_24x24.png ^
%%~nf_32x32.png ^
%%~nf_64x64.png ^
%%~nf_128x128.png ^
%%~nf_256x256.png %%~nf.ico
)