本帖最后由 Nsqs 于 2017-1-21 09:07 编辑
- @echo off
- set "folder=A" %和A文件夹放在一起,不是放在A文件夹里面%
- for /d %%1 in ("%folder%\*")do (
- for /d %%2 in ("%%1\*")do xcopy /eiy "%%1" "%~dp0\new\*"
- )
复制代码 或者灵活性高的方法- :on error resume next
- :sub class_bat
- ' 2>nul &@echo off&cls&set "folder=A" %和A文件夹放在一起,不是放在A文件夹里面%
- ' 2>nul &for %%1 in (%folder%)do set "folder=%%~dpnx1"
- ' 2>nul &(for /f %%1 in ('^(echo %folder%^&dir /s/b/ad %folder%\*^)^|cscript -nologo -e:"vbs" "%~0"')do if "%%1"=="." (echo 超出子目录层级,请重新分配目录级数!)else xcopy /eiy "%%1" "%~dp0\new\*")&pause&exit
- :end sub
- set ws=wsh.stdin
- set regexp=new regexp
- with regexp
- m=3 '是3级目录就修改为3
- .global=-1:.pattern="\\"
- s=ws.readline:n=.execute(s).count
- do
- s=ws.readline:c=.execute(s&"\").count+1
- if n+m>c then wsh.echo ".":wsh.quit
- if n+m=c then wsh.echo s
- loop until ws.atendofstream
- end with
复制代码
|