38、39、40行删掉,单独用这个
,弄了一个得运行两次BAT才能成功,第一次没检测到输出的index.html第二次检测到index.html才复制res所有文件夹- @echo off&setlocal EnableDelayedExpansion
- title 图片重命名生成网页,res文件夹必须和要处理图片文件夹在同一个目录
- for /f "delims=" %%a in ('dir /b /ad /s * ^| findstr /i /v "\\res$"^| findstr /i /v "\\thumbs$"') do (
- pushd %%a&set A=%%a
- @for /f "delims=" %%b in ('dir /a:d /B %%a\* ^| findstr /i /v "\\res$"^| findstr /i /v "\\thumbs$"') do (set B=%%b
- for /f "delims=" %%c in ('dir /b/a-d/oN "%%b\index.html"') do (
- popd
- if exist "!A!\!B!\index.html" md "!A!\res" & copy "%~dp0res" "!A!\res"
- ))
- )
- pause
复制代码 …………
另有可能用到缩略图转换- @echo off&setlocal enabledelayedexpansion&cd /d %~dp0
-
- if not exist "C:\Windows\System32\nconvert.exe" (
- echo 没有nconvert,请前往下面地址或其他网站下载,放入C:\Windows\System32
- echo,http://bcn.bathome.net/s/tool/index.html?key=nconvert
- pause&exit /b
- )
-
- set /p "str=请输入缩略图最大像素:"
- ::排除res、thumbs、slides文件夹
- for /f "delims=" %%a in ('dir /ad /b /s * ^| findstr /i /v "\\res$" ^| findstr /i /v "\\thumbs$" ^| findstr /i /v "\\slides$"') do (
- for %%i in ("%%a\*.jpg" "%%a\*.png" "%%a\*.bmp") do (
- if not exist "%%a\%%~nxi" md "%%a\thumbs")
- cd "%%a"&echo.&echo 进入 "%%a" 文件夹查找图片. . .&echo 缩略图将存放于各自文件夹的thumbs内. . .
- for /f "delims=" %%b in ('dir /a-d /b "*.jpg" "*.png"') do (
- for /f "tokens=1* delims=:" %%i in ('nconvert.exe -info "%%b"^|findstr /i /l /c:"Width"') do set W=%%j&set W=!W: =!
- for /f "tokens=1* delims=:" %%k in ('nconvert.exe -info "%%b"^|findstr /i /l /c:"Height"') do set H=%%l&set H=!H: =!
- if !W! leq !H! (set W=0&set H=!str!) else (set W=!str!&set H=0)
- nconvert -rmeta -quiet -overwrite -out jpeg -ratio -resize !W! !H! -c 8 -o "%%a\thumbs\%%~nb.jpg" "%%~nxb"
- )
- )
- echo.
- echo,创建缩略图完成. . .
- pause&exit /b
复制代码
|