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-01 14:44
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] DOS program or batch file to automatically change numeric filenames under DOS View 1,592 Replies 5
Original Poster Posted 2005-11-23 13:00 ·  中国 江苏 南京 电信
初级用户
Credits 92
Posts 28
Joined 2005-11-23 12:38
20-year member
UID 45780
Gender Male
From nanjin
Status Offline
Question for the experts: for the DOS batch file below, how should the program be written?
1. There are many TXT files named with numbers (from small to large). Now I need to change all those numeric filenames as required (for example: add 100 to all of them), still keeping them in ascending order.
2. Take the renamed TXT files and, at a specified time interval (such as 10 seconds), copy them one by one in ascending order
automatically to another place (such as C:\...TXT-----G:\...TXT)

The above is a major problem I have run into recently, I kneel and beg the experts to tell me
Floor 2 Posted 2005-11-24 13:14 ·  中国 重庆 巴南区 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
First say what your runtime environment is.
Also, what are the starting and ending values of your numbers?
If it is a system 2K or above, and the starting value is 1 and the ending value is 100, then it can be like this:
for /l %%a in (1,1,100) do ren %%a.txt %%a100.txt
for /l %%b in (1,1,100) do wait 10000 && copy %%a100.txt g:
http://www.msfans.net/bbs/
Floor 3 Posted 2005-11-24 23:51 ·  中国 辽宁 锦州 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
21-year member
UID 40733
Gender Male
Status Offline
I didn't quite understand your question. Do you want to add 100 to the numeric value, or add the characters 100 before or after the filename? You'd better give some examples of the filenames and what they become after renaming. Are these filenames consecutive? If they are numbers, then naturally there are smaller and larger ones, so what is the range?
Floor 4 Posted 2005-11-30 16:49 ·  中国 江苏 南京 电信
初级用户
Credits 92
Posts 28
Joined 2005-11-23 12:38
20-year member
UID 45780
Gender Male
From nanjin
Status Offline
Hello: the numeric filenames are all 14 digits long... for example 11112222333333.TXT..... add 100 from small to large
There are 58 TXT files in total...... waiting again for your reply, thanks
Floor 5 Posted 2005-12-07 11:34 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
To be honest-------your second explanation is even more confusing than the first one.
Floor 6 Posted 2005-12-07 21:36 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re kumho:

Your description of the problem really is somewhat vague and unclear. For example: you did not mention what system environment you are using, whether your filenames are consecutive numbers, and whether adding 100 is in the mathematical sense or the textual sense.

If you are using it under cmd, then it will not be very complicated; if under DOS, then some special handling is needed, but that only applies to the specific application, so you need to describe it as completely and clearly as possible.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: