代码中含有rd命令慎用,请备份好源文件。未测试:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /b /ad *,* *-* *、* *,*') do (
- set str=%%a
- for %%b in (, 、 -) do set str=!str:%%b= !
- for %%i in (!str!) do (
- if exist %%i (
- set /a _%%i+=1
- md "%%i(!_%%i!)"
- xcopy "%%a\*.*" "%%i(!_%%i!)\"
- ) else (
- md "%%i"
- xcopy "%%a\*.*" "%%i\"
- )
- )
- rd /s /q %%a
- )
- pause
复制代码
|