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-07-07 14:41
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] How to copy one file N times View 883 Replies 12
Original Poster Posted 2009-02-06 17:02 ·  中国 江西 九江 电信
新手上路
Credits 18
Posts 10
Joined 2009-01-23 16:21
17-year member
UID 137319
Gender Male
Status Offline
I want to copy the same file dozens of times in the same directory. How do I do this? Could someone tell me?

[ Last edited by HAT on 2009-2-7 at 11:41 ]
Floor 2 Posted 2009-02-06 18:04 ·  中国 江西 九江 电信
新手上路
Credits 18
Posts 10
Joined 2009-01-23 16:21
17-year member
UID 137319
Gender Male
Status Offline
Is the question too newbie-level, so nobody wants to answer?
Floor 3 Posted 2009-02-07 00:02 ·  中国 浙江 宁波 电信
初级用户
Credits 39
Posts 23
Joined 2009-02-05 21:38
17-year member
UID 138135
Gender Male
Status Offline
Put your file in one directory, for example: C:\test\ , and move y into the C:\test\ directory
Run this command any number of times: for %a in (*) do @copy /y bbb b%a
Or write this command into a BAT like this:
@echo off
cd c:\test\
for %a in (*) do @copy /y bbb b%a
0%


Then run the BAT batch file.

[ Last edited by q385131731 on 2009-2-7 at 00:17 ]
Floor 4 Posted 2009-02-07 00:21 ·  中国 江西 九江 电信
新手上路
Credits 18
Posts 10
Joined 2009-01-23 16:21
17-year member
UID 137319
Gender Male
Status Offline
I tried it, it doesn't work.
Floor 5 Posted 2009-02-07 00:31 ·  中国 浙江 宁波 电信
初级用户
Credits 39
Posts 23
Joined 2009-02-05 21:38
17-year member
UID 138135
Gender Male
Status Offline
Run this command any number of times: for %a in (*) do @copy /y bbb b%a
Floor 6 Posted 2009-02-07 00:33 ·  中国 浙江 宁波 电信
初级用户
Credits 39
Posts 23
Joined 2009-02-05 21:38
17-year member
UID 138135
Gender Male
Status Offline
There may be a problem with the batch file. I'm a newbie just like you too. Waiting for an expert to correct it.
With only a little superficial knowledge, I still try my best to help people.. Hope you understand.
Floor 7 Posted 2009-02-07 01:15 ·  中国 江西 九江 电信
新手上路
Credits 18
Posts 10
Joined 2009-01-23 16:21
17-year member
UID 137319
Gender Male
Status Offline
Haha, got it working.
Change this
@echo off
cd c:\test\
for %a in (*) do @copy /y bbb b%a
0%
change %a to %%a, and don't use the @ symbol

@echo off
cd c:\test\
for %%a in (*) do copy /y bbb b%%a
0%
and it works, but it can only copy once.

I just looked up a lot of materials, it should be written like this:
for /l %%a in (1,1,500) do copy a.txt a%%a.txt
That can copy it as many times as you want. If you want to copy it more or fewer times, just change that 500 to the number you want.
Thanks for your reply anyway.
Floor 8 Posted 2009-02-07 07:34 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
It depends on what you actually need, there are still many ways to write it,
set /a a=0
set /a v=10
:test
set /a a=a+1
copy %0 %a%.bat
if %a% GEQ %v% goto :eof
goto :test

pause

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 9 Posted 2009-02-07 11:44 ·  中国 江西 九江 电信
新手上路
Credits 18
Posts 10
Joined 2009-01-23 16:21
17-year member
UID 137319
Gender Male
Status Offline
Thanks for the pointers.
Floor 10 Posted 2009-02-07 12:27 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
copy %0 %random%.bat
start %0

And that's how an evil piece of code is born

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 11 Posted 2009-02-07 20:32 ·  中国 重庆 联通
新手上路
Credits 1
Posts 1
Joined 2009-01-29 22:17
17-year member
UID 137613
Gender Male
Status Offline
Floor 12 Posted 2009-05-18 22:17 ·  中国 江苏 泰州 电信
初级用户
Credits 22
Posts 22
Joined 2005-10-24 21:39
20-year member
UID 44006
Status Offline
Learned something, good stuff, thanks!
Floor 13 Posted 2009-05-19 11:12 ·  中国 江苏 无锡 锡山区 电信
新手上路
Credits 11
Posts 10
Joined 2008-11-25 21:02
17-year member
UID 132088
Gender Male
Status Offline
Forum Jump: