[英]Batch file with mogrify into folders
I can shrink some images with imagemagick using mogrify in a batch file but I'm having trouble setting the destination directory 我可以使用批处理文件中的mogrify使用imagemagick缩小某些图像,但是在设置目标目录时遇到问题
@ECHO OFF
SET scriptdir=%~dp0
cd /d %imagedir%
SET tb="thumbs"
IF NOT EXIST "%imagedir%"/%tb% MKDIR "%imagedir%"/%tb%
FOR %%a in (*.tif) do (
mogrify -resize 42x42 -format jpg -quality 100 %%a
move %%a %imagedir%/%tb%
)
The above script does what I want, but it's bugging me that I have to use move command to place the images there instead of creating them there. 上面的脚本可以实现我想要的功能,但令我感到困扰的是,我必须使用move命令将图像放置在此处,而不是在此处创建图像。
Just add -path XYZ
into your mogrify
command to get ImageMagick to write the output files in directory XYZ
. 只需将-path XYZ
添加到您的mogrify
命令中,以使ImageMagick将输出文件写入目录XYZ
。 For example: 例如:
mkdir results
mogrify -path results -resize ... inputfile.jpg
The whole point of mogrify
though is that you don't need a loop , you just do all the files in one go: mogrify
的全部目的是不需要循环 ,只需一次完成所有文件:
mogrify -path results -format jpg -resize 42x42 *.tif
Use option -write filename
, documented as: write images to this file
使用选项-write filename
,记录为: write images to this file
mogrify -resize 42x42 -format jpg -quality 100 -write %imagedir%\%tb%\%%a %%a
I used %imagedir%\\%tb%\\%%a
to fully specify an output filename, and I changed the slashes to Backslashes. 我使用%imagedir%\\%tb%\\%%a
来完全指定输出文件名,然后将斜杠更改为反斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.