出于善意提醒,ai的很多代码即使能运行成功,但也是错的,不要被误导。以下代码一步到位,完成分类,避免了多余的添加序号问题。
- @echo off
- cd /d "%~dp0"
- set "dp=%~dp0"
- set "dp=%dp:\=\\%"
- set n=1
- for /f "delims=" %%i in ('dir /b /s /a-d ^|find /v "%~f0" ^|findstr /rvibc:\\"%dp%[1-2][0-9][0-9][0-9]\\\\"') do (
- for /f "tokens=1-2 delims=/" %%a in ("%%~ti") do (
- setlocal
- if "%%b" leq "06" (
- call :1 "%%a\上半年" "%%i"
- ) else (
- call :1 "%%a\下半年" "%%i"
- )
- endlocal
- )
- )
- for /f "delims=" %%i in ('dir /b /s /ad ^|sort /r') do (
- rd "%%i" 2>nul
- )
- pause
- exit
-
- :1
- md "%~1" 2>nul
- if not exist "%~1\%~n2%m%%~x2" (
- move "%~2" "%~1\%~n2%m%%~x2"
- exit /b
- )
- set /a n+=1
- set m=_%n%
- goto :1
复制代码
|