|
- call :dirlist listPre
- mkdir Dir2
- call :dirlist listLater
- rem 删除不同文件夹,删除相同文件夹使用:call :delDir true
- call :delDir false
- echo 运行前文件夹:%listPre%
- echo 运行后文件夹:%listLater%
- ::结束批处理
- ::======================
- goto :EOF
- :dirlist
- set listTemp=<nul
- FOR /F "usebackq tokens=* delims=" %%i in (`dir *.* /B /A:D`) do (
- set "listTemp=%%i/!listTemp!"
- )
- set "%~1=%listTemp%"
- goto :EOF
- ::======================
- goto :EOF
- :delDir
- set listLaterloop=%listLater%
- :delDir0
- FOR /F "usebackq tokens=1* delims=/" %%i in ( `echo !listLaterloop!` ) do (
- if defined listLaterloop (
- set "i=%%i"
- set "j=%%j"
-
- set "listPreloop=%listPre%"
- set "found=false"
- :delDir1
- FOR /F "usebackq tokens=1* delims=/" %%k in ( `echo !listPreloop!` ) do (
- if defined listPreloop (
- if !i!==%%k set "found=true"
- set "listPreloop=%%l" &goto :delDir1
- )
- )
- if !found!==%~1 rd /s /q !i! && echo 已删除文件夹:!i!
- set "listLaterloop=!j!" &goto :delDir0
- )
- )
- goto :EOF
复制代码 |
|