ANSI保存,输出*_cut.*- @echo off
- if "%~1"=="" ( echo 请拖动图片文件到bat! & pause & exit )
- REM 设置nconvert.exe路径
- set "path=%path%;C:\Users\lenovo\Desktop\XnView"
- :loop
- call :cutImg "%~1"
- shift /1
- if not "%~1"=="" goto :loop
- pause&exit
-
- :cutImg
- echo 处理: %~1
- echo %~x1 | findstr /i "jpg jpeg png bmp gif png" >nul 2>nul || (
- echo 非图片文件!
- echo -----------------------------------------
- goto :eof
- )
- set "width=0" & set "height=0"
- for /f "tokens=2 delims=:" %%i in ('nconvert -info "%~1" ^| findstr /i "width height"') do (
- call set /a "0/%%width%%" >nul 2>nul && set "height=%%i" || set "width=%%i"
- )
- echo 原尺寸: %width% %height%
- if %width% equ %height% ( echo ----------------------------------------- & goto :eof )
- if %width% gtr %height% set "newsize=1920 %height%
- if %width% lss %height% set "newsize=%width% 1080"
- echo 新尺寸: %newsize%
- nconvert -quiet -overwrite -resize %newsize% -o "%~dp1%~n1_cut%~x1" "%~1" && echo 完成!
- echo -----------------------------------------
复制代码
|