使用ImageMagick批量创建循环以进行多次导出 [英] create loop in batch for multiple export with ImageMagick

查看:176
本文介绍了使用ImageMagick批量创建循环以进行多次导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个处理多个图像文件的批处理文件。

Im trying to make a batch file that process multiple image files.

文件命名为P_1316_0001.png P_1316_0002.png P_1316_0003.png等..
LETs sqy P_1316 is VARSESSION)
感谢ImageMagick程序我可以直接用批量转换图像。

The files are named P_1316_0001.png P_1316_0002.png P_1316_0003.png etc.. LETs sqy P_1316 is VARSESSION) thanks to the ImageMagick program i can convert an image directly with batch.

基本上我想做的是:

创建一个将递增的变量,直到该文件夹​​中没有更多要转换的文件为止。将文件从png转换为jpg(转换%VARSESSION%%i%.png%VARSESSION%%i%.jpg),假设我是0001

Create a variable that would increment until there is no more file to convert in the folder. Comvert the file from png to jpg (convert %VARSESSION%%i%.png %VARSESSION%%i%.jpg) assuming that i is 0001

我希望你能帮助我。
i谢谢你

Well i hope you can help me. i thank you

Daniel

推荐答案

你是对你的问题有一点限制,但要符合你指定的精确参数,

You're being a little restrictive with your question, but to suit the precise parameters you've specified,

SETLOCAL ENABLEDELAYEDEXPANSION
for /l %%i in (10001,1,19999) do (
 set numb=%%i
 ECHO if exist %varsession%_!numb:~1!.png convert %varsession%_!numb:~1!.png %varsession%_!numb:~1!.jpg
)
ENDLOCAL

但是有更好的方法,例如

But there are much better ways, such as

for /f %%i in ('dir /b /a-d %varsession%_*.png') do (
ECHO convert %%i %%~ni.jpg
)

假设要处理所有匹配%varsession%_ *。png的文件。

Assuming that all files matching %varsession%_*.png are to be processed.

注意:关键字ECHO插入显示批处理建议做什么。删除 ECHO 以实际执行操作

Note: keyword ECHO inserted to SHOW what the batch proposes to do. Remove the ECHO to actually perform the action

这篇关于使用ImageMagick批量创建循环以进行多次导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆