- @echo off
- rem 设置源目录
- set "ScDir=d:\temp"
-
- cd /d "%ScDir%"
- for /f "delims=" %%a in ('dir /a-d /b') do (
- set "f1=%%~na"
- setlocal enableDelayedExpansion
- set "f1=!f1:~0,1!"
- call :scan_dir "%ScDir%" "!f1!" scDir
- if not "!scDir!"=="" (move /y "%%a" "!scDir!" )>nul
- endlocal
- )
- pause&exit
-
- :scan_dir dir str rdir
- setlocal enableDelayedExpansion
- set "scDir=%~1"
- pushd "%scDir%"
- for /f "delims=" %%a in ('dir /ad /b') do (
- set "d1=%%a"&&set "d1=!d1:~0,1!"
- if %~2==!d1! (popd&endlocal&set "%3=%%a"&goto:eof)
- )
复制代码
|