China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-05 03:18
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Batch create folders named 1 to 100 View 3,100 Replies 34
Floor 16 Posted 2005-03-10 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
Come on
md 666
cd 666
for %%a in (1 2 3 4 5 6...100) do echo .>&%a.txt
http://www.msfans.net/bbs/
Floor 17 Posted 2005-03-10 00:00 ·  中国 重庆 万州区 电信
初级用户
Credits 140
Posts 16
Joined 2005-03-10 00:00
21-year member
UID 36868
Gender Male
Status Offline
Please, chenhui530, give me some advice! Thank you!
Floor 18 Posted 2005-03-10 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
I don't have the Windows 98 system, so I can't test what I wrote either.
http://www.msfans.net/bbs/
Floor 19 Posted 2005-03-10 00:00 ·  中国 重庆 万州区 电信
初级用户
Credits 140
Posts 16
Joined 2005-03-10 00:00
21-year member
UID 36868
Gender Male
Status Offline
Please write more, I'll test it and tell you the result. Let's work together to solve this problem. Do you have confidence??? Greatly appreciate it!!!!
Floor 20 Posted 2005-03-10 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
I thought about it and haven't come up with a way to solve this problem without using third-party tools.
If third-party tools are allowed, you can use STRINGS to complete this operation to make the variable automatically +1. If the variable is greater than 101, it will automatically exit. The code is as follows:
:kaishi
strings a=add %b%,1
if not exist %a% echo 1>%a%.txt
strings b=add %a%,1
if %b%==101 goto end
goto kaishi
:end
http://www.msfans.net/bbs/
Floor 21 Posted 2005-03-11 00:00 ·  中国 重庆 万州区 电信
初级用户
Credits 140
Posts 16
Joined 2005-03-10 00:00
21-year member
UID 36868
Gender Male
Status Offline
I just tested, it doesn't work! Every time I have to manually edit an empty text document, which is similar to the following code
md 666
cd 666
for %%a in (1 2 3 4 5 6) do copy con %%a.txt Now the key problems to be solved are two 1, how to automatically generate folders or files from (1~100) without manually filling in numbers! 2, how to automatically edit an empty text document Do you have any good methods, let's study together, I believe that without third-party software, DOS batch processing can achieve the expected goal!!!
Floor 22 Posted 2005-03-11 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
: :kaishi
strings a=add %b%,1
if not exist %a% echo 1>%a%.txt
strings b=add %a%,1
if %b%==101 goto end
goto kaishi:end
This is the answer you want呀
http://www.msfans.net/bbs/
Floor 23 Posted 2005-03-11 00:00 ·  中国 重庆 万州区 电信
初级用户
Credits 140
Posts 16
Joined 2005-03-10 00:00
21-year member
UID 36868
Gender Male
Status Offline
How to automatically edit an empty text document
Floor 24 Posted 2005-03-11 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
Below is the quote of 7451's post on 2005-3-11 9:54:38:
How to automatically edit an empty text document

Please clarify your meaning
http://www.msfans.net/bbs/
Floor 25 Posted 2005-03-11 00:00 ·  中国 重庆 万州区 电信
初级用户
Credits 140
Posts 16
Joined 2005-03-10 00:00
21-year member
UID 36868
Gender Male
Status Offline
Create an empty text document using batch processing
Floor 26 Posted 2005-03-11 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
The following is a quote from 7451's post on 2005-3-11 14:31:30:
Create an empty text document using batch processing

This problem is relatively difficult. It's difficult with DOS but very simple using other scripting languages
http://www.msfans.net/bbs/
Floor 27 Posted 2005-03-11 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
1. It is suggested that the original poster (LZ) write a good title for the post. Such titles are the most likely to be overlooked. Please refer to the link in my signature.
2. Regarding your question: The way "for %%a in (1 2 3 4 5 6...100) do md %%a" is definitely not feasible because the command line exceeds the limit of 255 characters. It can be considered to separate the for command and write it in several parts.
md 666
cd 666
for %%a in (1 2 3 4 5 6...100) do echo %%a>%%a.txt
The above commands should be run in a batch file. If run directly in the command line, %%a should be changed to %a. These are all basics of DOS. It is suggested that the original poster first study the post "Hand-in-Hand to Write Batch Files for You".
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 28 Posted 2006-06-20 15:48 ·  中国 湖南 长沙 中移铁通
初级用户
Credits 87
Posts 33
Joined 2006-06-20 12:22
20-year member
UID 57306
Gender Male
From cs
Status Offline
Dim fso, f, n
n = InputBox("Please enter the number of folders to create:")
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 1 To n
Set f = fso.CreateFolder(i)
Next
Floor 29 Posted 2006-06-20 16:53 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
md 666
cd 666
md 1 2 3 4 5 6 7 8 9.....50
md 51 52 53 54 ......100

I don't know if it will work. It should be okay on systems above 2000. I don't know if it works on 98.
Floor 30 Posted 2006-06-21 09:17 ·  中国 北京 鹏博士BGP
中级用户
★★
Credits 404
Posts 179
Joined 2006-03-30 14:44
20-year member
UID 53056
Status Offline
```
for %%a in (1 2 3 4 5 6 7 8 9) do for %%b in (1 2 3 4 5 6 7 8 9 0) do ( md %%a%%b ) & (md %%b) & (ren 0 100)
```
Forum Jump: