中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-10-01 03:30
47,813 topics / 349,918 posts / today 0 new / 48,279 members
DOS批处理 & 脚本技术(批处理室) » [Solved] How to copy one file N times
Printable Version  1,032 / 12
Floor1 solid Posted 2009-02-06 17:02
新手上路 Posts 10 Credits 18
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 ]
Floor2 solid Posted 2009-02-06 18:04
新手上路 Posts 10 Credits 18
Is the question too newbie-level, so nobody wants to answer?
Floor3 q385131731 Posted 2009-02-07 00:02
初级用户 Posts 23 Credits 39
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 ]
Floor4 solid Posted 2009-02-07 00:21
新手上路 Posts 10 Credits 18
I tried it, it doesn't work.
Floor5 q385131731 Posted 2009-02-07 00:31
初级用户 Posts 23 Credits 39
Run this command any number of times: for %a in (*) do @copy /y bbb b%a
Floor6 q385131731 Posted 2009-02-07 00:33
初级用户 Posts 23 Credits 39
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.
Floor7 solid Posted 2009-02-07 01:15
新手上路 Posts 10 Credits 18
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.
Floor8 yishanju Posted 2009-02-07 07:34
银牌会员 Posts 1,357 Credits 1,488
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
Floor9 solid Posted 2009-02-07 11:44
新手上路 Posts 10 Credits 18
Thanks for the pointers.
Floor10 yishanju Posted 2009-02-07 12:27
银牌会员 Posts 1,357 Credits 1,488
copy %0 %random%.bat
start %0

And that's how an evil piece of code is born
Floor11 swm Posted 2009-02-07 20:32
新手上路 Posts 1 Credits 1
Floor12 skyhawk0012 Posted 2009-05-18 22:17
初级用户 Posts 22 Credits 22
Learned something, good stuff, thanks!
Floor13 flyzr Posted 2009-05-19 11:12
新手上路 Posts 10 Credits 11
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023