本帖最后由 qixiaobin0715 于 2023-1-11 16:45 编辑
1.以下代码未经测试,运行前请备份好源文件;
2.将下面代码均放在主文件夹中,保存为ANSI编码;
3.假设图片文件为jpg格式,其它格式可修改批处理1第8行。
批处理1- @echo off
- md NewFolder
- for /d %%a in (*) do (
- setlocal enabledelayedexpansion
- set /a min=5,max=10,n=0
- set /a "num=!random!%%(max-min+1)+min"
- pushd "%%a"
- for /f "delims=" %%i in ('dir /b /a-d *.jpg') do (
- set /a n+=1
- set _!random!-!n!=%%i
- )
- set /a x=n-num
- md "%~dp0NewFolder\%%a"
- for /f "tokens=2 delims==" %%i in ('set _^|more +!n!') do (
- copy "%%j" "%~dp0NewFolder\%%a\"
- )
- popd
- endlocal
- )
- pause
复制代码 批处理2- @echo off
- for /f "delims=" %%i in ('dir /b /s /ad NewFolder') do (
- move /y "%%i\*.*" "%~dp0%%~nxi\"
- rd "%%i"
- )
- rd NewFolder
- pause
复制代码
|