怎样用批处理这样建文件夹?

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:20:38
可不可以用批处理
建一亿个文件夹啊?
10个文件夹,每个子文件夹下都有10个文件夹,子子子...文件夹下也有10个文件夹.... 建8层..
谁会啊?
0 1 2 3 4 5 6 7 8 9
0123... 0123... ...
0123... 0123... ...
0123... 0123... ...
... ... ...

8层
可不可以简单些的啊?
可不可以用函数啊?
这样无限循环的...弄死人的啊?
我只想8层左右.

3楼的
你这个不行啊..
例如:start .\1\this.bat
是调用.\1\下的this.bat 而路径还是上一句的路径
所以只会出现1个this.bat在.\1\下
进入死循环
应改成copy this.bat 1
cd 1
start this.bat
cd ..
copy this.bat 2
cd 2
start this .bat

编辑:反驳楼上的,用FOR很难实现,因为楼主要求的目录结构其实是TREE给够,而不是多维结构,我认为一定要用RECURSIVE才能完成.用FOR很难写.

好像没什么难度.
很容易理解的,建10个文件夹,然后把批处理本身复制到子文件夹,再启动文件夹里的批处理.这个批处理请另存为this.bat

如果一定要八层,建议用Subst虚拟成盘符,再从%cd%变量中读取\号的个数要判断是否有八层目录,有的话,就停了,没有话,就一直创建,估计这个方法可以很快死机.

md 1
md 2
md 3
md 4
md 5
md 6
md 7
md 8
md 9
md 10
copy this.bat 1
start .\1\this.bat

copy this.bat 2
start .\2\this.bat

copy this.bat 3
start .\3\this.bat
copy this.bat 4
start .\4\this.bat
copy this.bat 4
start .\5\this.bat
copy this.bat 6
start .\6\this.bat
copy this.bat 7
start .\7\this.bat
copy this.bat 8
start .\8\this.bat
copy this.bat 9
start .\9\this.bat
copy this.bat 10
start .\10\this.bat

可以,用循环嵌套建立就是了。

用for 循环可以实现,但是没什么意义,因为最多到255屋基本上就不能再建立了。
例如下面的代码就可以实现类似的功能,