本帖最后由 tmplinshi 于 2011-6-18 15:14 编辑
| @echo off | | setlocal disabledelayedexpansion | | | | set "str_old=印刷" | | set "str_new=电子" | | set "drive=c d e f g h i j k l m n o p q r s t u v w x y z" | | | | for %%d in (%drive%) do ( | | if exist %%d: ( | | echo 正在处理 %%d 盘... | | for /f "delims=" %%f in (' dir /a /b /s "%%d:\*%str_old%*" ') do ( | | set fpath=%%~dpf | | set fname=%%~nxf | | setlocal enabledelayedexpansion | | set "fpath=!fpath:%str_old%=%str_new%!" | | set "fname_new=!fname:%str_old%=%str_new%!" | | ren "!fpath!!fname!" "!fname_new!" || ( | | | | for %%f in ("!fpath!!fname!") do ( | | set a=%%~af | | if "!a:h=!" neq "!a!" set a=!a! -h | | if "!a:s=!" neq "!a!" set a=!a! -s | | set a=!a:* =! | | attrib !a! "!fpath!!fname!" | | ren "!fpath!!fname!" "!fname_new!" | | attrib !a:-=+! "!fpath!!fname_new!" | | ) | | ) | | endlocal | | ) | | ) | | ) 2>nul | | | | pauseCOPY |
|