本帖最后由 bailong360 于 2016-1-31 17:42 编辑
- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b *.txt') do (
- set "FileName=%%~ni"
- set "FileName=!FileName:.=$ !"
- set "NewName=$"
- for %%j in (!FileName!) do (
- set "TmpName=%%j"
- if not "!TmpName:~-1!"=="$" (
- for /l %%k in (0 1 9) do set "TmpName=!TmpName:%%k=%%k《!"
- for /l %%k in (0 1 9) do set "TmpName=!TmpName:《%%k=%%k!"
- set "NewName=!NewName!.!TmpName!》"
- ) else set "NewName=!NewName!.!TmpName:~0,-1!"
- )
- echo ren "%%~nxi" "!NewName:$.=!%%~xi"
- )
- pause
复制代码 9楼的第三方解法多方便,又迅速
确认无误后将echo去掉- @for /f "delims=" %%i in ('dir /a-d /b *.txt^|ssed -R "s/([0-9.]+)(.*?)(\.txt)/\"\0\" \"\1《\2》\3\"/g"') do @ren %%i
复制代码 来个ssed的
===========
话说,LZ你的文件是真的没有后缀还是后缀被你省略掉了?? |