日期:2014-05-17  浏览次数:20753 次

想批量生成比如10层,每层10个文件夹,每个文件夹里10个文本文件,该如何编写?
比如我想批量生成比如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 off
for /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
  )
)