备忘
- @echo off&setlocal EnableDelayedExpansion
-
- cd /d %~dp0
-
- ::遍历当前目录下 *.txt 扩名的文件
- for /f "delims=" %%i in ('dir /b /a-d /s "*.txt"') do (
- ::原始路径
- set nam=%%i
- ::扩名
- set ext=%%~xi
- ::文件名
- set fn=%%~nxi
- ::目录
- set pt=%%~dpi
- ::新文件名
- set newfile=!fn:_0=!
- echo 原文件名:!fn!
- echo 新文件名:!newfile!
- ren !fn! !newfile!
- echo.
- )
-
- echo 操作完成
-
- pause