ImageMagick的批处理命令,用于转换目录中的所有文件和Windows上的子目录 [英] Batch command for ImageMagick to convert all files in a directory and sub-directories on windows
问题描述
我在文件夹和子文件夹中有数千个SVG。我想要的是将所有这些批量转换为 jpg 或 png 图像。
I have thousands of SVG's in a folder and sub-folders. What I want is to batch convert all of them to jpg or png images.
有人可以帮我写一个ImageMagick(windows)的命令,它可以查找所有svg并将其转换为原始名称并将它们保存在同一个jpg / png中目录?
Can someone help me write a command for ImageMagick (windows), which can find and convert all the svg's to jpg/png with their original names and keep them in the same directories?
以下是示例结构:
C:\SVG\BusinessMan.svg
C:\SVG\Models\Home.svg
C:\SVG\Underlines\underline.svg
转换后我想要这样:
C:\SVG\BusinessMan.svg
C:\SVG\BusinessMan.jpg
C:\SVG\Models\Home.svg
C:\SVG\Models\Home.jpg
C:\SVG\Underlines\underline.svg
C:\SVG\Underlines\underline.jpg
推荐答案
尝试使用 FOR
从根文件夹中循环 / R
标记:
Try with a FOR
loop with /R
flag from inside your root folder:
FOR /R %a IN (*.svg) DO convert "%~a" "%~dpna.jpg"
此命令将转换所有 .svg
从您启动命令的根文件夹下的子目录中的文件。
this command will convert all the .svg
files in your sub-directories under the root folder you launched your command from.
以上命令适用于命令行,如果您打算在批处理文件(.bat)中使用该命令,请记住使用 %%
而不是%
:
Above command works for command line, if you plan to use the command inside a batch file (.bat) remember to use %%
instead of %
:
FOR /R %%a IN (*.svg) DO convert "%%~a" "%%~dpna.jpg"
有关详细信息,请参阅Imagemagick文档的此页面
See this page of Imagemagick documentation for more info
这篇关于ImageMagick的批处理命令,用于转换目录中的所有文件和Windows上的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!