首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > windows >

怎么批处理生成N个层次的M个文件夹下面再带Z个文件

2012-02-23 
如何批处理生成N个层次的M个文件夹下面再带Z个文件比如我想批量生成比如10层,每层10个文件夹,每个文件夹里

如何批处理生成N个层次的M个文件夹下面再带Z个文件
比如我想批量生成比如10层,每层10个文件夹,每个文件夹里10个文本文件,该如何编制BAT文件?

@echo off & setlocal enabledelayedexpansion
dir *.* /s > wang.txt
for /l %%a in (1 1 10) do (
  md %%a
  for /l %%i in (1 1 10) do (copy wang.txt %%a\!random!.txt)

for /l %%b in (1 1 10) do (
  md %%a\%%b
  for /l %%i in (1 1 10) do copy wang.txt %%a\%%b\!random!.txt)


for /l %%c in (1 1 10) do (
  md %%a\%%b\%%c
  for /l %%i in (1 1 10) do copy wang.txt %%a\%%b\%%c\!random!.txt)
。。。。

)

pause


总感觉这样好像很笨,有没什么好办法啊?


[解决办法]
test.bat

BatchFile code
@echo offfor /l %%a in (1,1,10) do (  for /l %%b in (1,1,10) do (    for /l %%c in (1,1,10) do (      for /l %%d in (1,1,10) do (        for /l %%e in (1,1,10) do (          for /l %%f in (1,1,10) do (            for /l %%g in (1,1,10) do (              for /l %%h in (1,1,10) do (                for /l %%i in (1,1,10) do (                  for /l %%j in (1,1,10) do (                    md "D:\%%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h\%%i\%%j"                  )                )              )            )          )        )      )    )  ))
[解决办法]
test.bat

BatchFile code
@echo offfor /l %%a in (1,1,10) do (  for /l %%b in (1,1,10) do (    for /l %%c in (1,1,10) do (      for /l %%d in (1,1,10) do (        for /l %%e in (1,1,10) do (          for /l %%f in (1,1,10) do (            for /l %%g in (1,1,10) do (              for /l %%h in (1,1,10) do (                for /l %%i in (1,1,10) do (                  for /l %%j in (1,1,10) do (                    md "D:\test\%%a\%%b\%%c\%%d\%%e\%%f\%%g\%%h\%%i\%%j"                  )                )              )            )          )        )      )    )  ))for /r "D:\test\" %%a in (.) do (  for /l %%b in (1,1,10) do (    >%%a\%%b.txt echo ljc007  )) 

热点排行