【解决方案】
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA
test-1.bat- @echo off
- REM 1. 下载并安装 ImageMagick 这个命令行工具
- REM https://imagemagick.org/script/download.php#windows
- REM 2. 根据自己电脑实际安装路径设置以下临时环境变量
- set "path=C:\Program Files\ImageMagick;%path%"
-
- REM 设置待处理的图片所在的文件夹
- set "PictureFolder=C:\Test"
- REM 只处理指定宽和高的图片
- set "OldPixel=1500x1500"
- REM 处理之后的宽和高
- set "NewPixel=800x800"
-
- pushd "%PictureFolder%"
- set "NewFolder=%TargetPixel%"
- if not exist "%NewFolder%" (
- md "%NewFolder%"
- )
- for /f "delims=" %%i in ('dir /b /a-d *.jpg') do (
- identify.exe -format "%%[w]x%%[h]" "%%i" | findstr "%NewPixel%" >nul 2>&1
- if not errorlevel 1 (
- move "%%i" "%NewFolder%"
- )
- )
- popd
-
- mogrify.exe "%PictureFolder%\%NewFolder%\*.jpg" -resize %NewPixel% "%PictureFolder%\%NewFolder%\*.jpg"
- pause
复制代码
|