Converting images within latex in windows

I have LaTeX code which works well in Linux, but I need to make it work in Windows.

MWE:

\documentclass[a4paper,12pt]{book}

\usepackage{graphicx}

\DeclareGraphicsExtensions{.pdf,.png,.jpg,.svg}

\DeclareGraphicsRule{.svg}{pdf}{.pdf}%
{%
inkscape -D -z --file=#1 --export-pdf=dirname #1/basename #1 .svg-svg-converted-to.pdf %
}

\begin{document}

\includegraphics{svg_example}

\end{document}


I found this question: Using macros in \DeclareGraphicsRule statement using shell command which seems to be the same, but commands from its answers don't work because there are not any filepath.

• Is inkscape in your Windows PATH variable? Are you running LaTeX with -shell-escape? – schtandard May 1 at 16:18
• First I hope you are not trying to shell paths between Linux and Windows apps on WSL, this is tough enough just using windows to windows ARE TeX and InkScape BOTH installed in windows ? if so then the last time I wrote pitfalls was here tex.stackexchange.com/questions/482626/texniccenter-and-svg – user170109 May 1 at 16:46
• @schtandard Yes, Inkscape is in PATH variable and I'm running LaTeX with -shell-escape – Shalom Alecheim May 1 at 17:22
• Ok, then there should not be an issue with the setup. I don't know about the shell command itself, but I'd recommend using svg`. This package takes care of all that and also conveniently places all the generated files in a separate folder. – schtandard May 1 at 17:41