本帖最后由 tmplinshi 于 2011-5-31 00:18 编辑
- @echo off
- SetLocal
- set "prefix=xbs"
- set "_cd=%cd%"
- for /f "usebackq delims=" %%a in ("a.txt") do (
- set path_now=%%~dpa
- SetLocal EnableDelayedExpansion
- if /i "!path_now!" neq "!path_last!" (
- EndLocal
- set path_last=%%~dpa
- set n=
- cd /d %%~dpa
- if exist "%prefix%*.jpg" ren "%prefix%*.jpg" "*.*.jpg"
- for /f "delims=" %%i in (' dir /b "*.jpg" ') do (
- set file=%%i
- SetLocal EnableDelayedExpansion
- ren "!file!" "!prefix!!n!.jpg"
- EndLocal
- set /a n += 1
- )
- ) else EndLocal
- )
- cd /d "%_cd%"
复制代码
|