本帖最后由 xp3000 于 2023-4-1 22:42 编辑
- @echo off
- REM 保存为ANSI编码的BAT
- set n=0
- set m=499
- set Folder=0001-0499
- md "%Folder%"
- setlocal enabledelayedexpansion
- for /f "tokens=1,* delims=:" %%a in ('dir /b /a-d /on^|findstr /n /e "\.mp3 \.m4v"') do set x=%%a
- set xx=000%x%
- for /f "delims=" %%i in ('dir /b /a-d /on^|findstr /e "\.mp3 \.m4v"') do (
- set /a n+=1
- if !n! lss !m! (
- move "%%i" "!Folder!\"
- ) else (
- move "%%i" "!Folder!\"
- set /a m+=500
- set /a n1=n+1
- set /a n2=n+500
- set n1=000!n1!
- set n2=000!n2!
- if !m! geq !x! (
- set Folder=!n1:~-4!-!xx:~-4!^(完^)
- ) else (
- set Folder=!n1:~-4!-!n2:~-4!
- )
- md "!Folder!
- )
- )
复制代码 3楼代码小改,刚开始拿700个文件测试遗漏了后面的- @echo off
- REM 移动子文件夹文件到批处理文件夹
- for /f "delims=" %%a in ('dir /a:d /b') do (
- pushd "%%a"
- for /f "delims=" %%b in ('dir /b /a-d "*.*"') do (
- move "%~dp0%%a\%%~nxb" "%~dp0%%~nxb"
- )
- popd
- rd /s /q "%%a"
- )
复制代码
|