所有文件夹下的文件,按文件所在的文件夹的名称来命名,是这个意思吗?- @echo off
- setlocal enabledelayedexpansion
- set "n='
- for /f "delims=" %%i in ('dir /s/b/ad') do (
- pushd "%%~fsi"&call :a "%%~ni"
- for %%a in (*) do if defined %%~xa set "%%~xa="
- )
- pause&exit
-
- :a
- for /f "delims=" %%i in ('dir /b/aa') do (
- if not defined %%~xi call :b "%%~xi" "%~1"&set "%%~xi=i"
- )
- goto :eof
-
- :b
- for /f "delims=" %%a in ('dir /b/aa *%~1') do (
- ren "%%~fsa" "%~2!n!%%~xa" 2>nul
- set/a n+=1
- )
- set "n="
- goto :eof
复制代码 我这边测试可以,你用一下。 |