本帖最后由 Five66 于 2024-4-7 19:51 编辑
保存为ansi编码的bat
文件夹名最好不要包含^&%之类的特殊字符- @echo off
-
- if "%~1" == "%cd%\" echo error&pause&exit/b
- set bbb=""%*
- set bbb=%bbb:~2%
-
- setlocal enabledelayedexpansion
- if exist "!bbb!" (
- cd /d !bbb!
- if errorlevel 1 endlocal&pause&exit/b
- for %%i in ("!cd!") do endlocal&cd /d "%%~i"
- ) else endlocal&echo error&pause&exit/b
-
- set "ddd=%date:/=-%"
- for /r %%i in (*.doc) do (
- set name=%%~ni
- set ext=%%~xi
- setlocal enabledelayedexpansion
- rename "!name!!ext!" "!name:~,2!-%ddd%!ext!"
- endlocal
- )
-
- echo done&pause
复制代码
|