Here is an ImageMagick based solution to convert all svg files in a given directory to ico files:
D:\Customize\Themes\Icons\ImageMagick\magick mogrify -format ico -density 1200 -background transparent -trim -resize 256x256 -gravity center -extent 256x256 -define icon:auto-resize E:\SVG\*.svg
Explanation:
mogrify: like convert, but allows processing multiple files in batch mode.
-format ico: our target file format. Creates .ico files instead of overwriting the source file (as mogrify does by default).
-density 1200: since we can't specify the target pixel size that ImageMagick should rasterize the SVG to (it will be rasterized at the default density first and then scaled), we will rasterize the SVG at an insanely high resolution (1200 dpi) to ensure that the image will be reduced to 256x256 instead of enlarged.
-background transparent: The background will be displayed as transparent.
-trim: remove the existing border around the image.
-resize 256x256: scale the image so that the longest side has 256 pixels, preserving the aspect ratio.
-gravity center -extent 256x256: enlarge the canvas, making sure that the short side also has 256 pixels. The existing image is center aligned. This is necessary because we need a square image as the basis for the ICO file.
-define icon: auto-resize: include not only the 256x256 image, but also all recommended reduced resolutions (e.g. 32x32) in the ICO file.