中国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-08-11 22:42
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] How do I copy a file into every subdirectory?
Printable Version  1,240 / 12
Floor1 dingamao Posted 2007-04-29 01:00
初级用户 Posts 47 Credits 118
When we use del, it has a /S parameter that can operate on all subdirectories~
But going the other way around, if I want to copy a file (say dos.txt) into all subdirectories of some partition, how should I do it?
copy doesn't provide a /S parameter either :(
Floor2 bjsh Posted 2007-04-29 01:08
银牌会员 Posts 621 Credits 2,000
Search ;

This kind of question has been discussed way too many times
Floor3 zhoushijay Posted 2007-04-29 01:15
高级用户 Posts 375 Credits 845
The OP can try thinking about it like this:
Use dir's /s parameter together with a for loop.
Floor4 dikex Posted 2007-04-29 02:25
高级用户 Posts 366 Credits 788
Floor5 dingamao Posted 2007-04-29 02:42
初级用户 Posts 47 Credits 118
Originally posted by dikex at 2007-4-28 01:25 PM:
for /r d:\ %%i in (^") do copy dos.txt "%%i

That really is correct, thank you very much indeed! I'd like to ask, what exactly does ^ do here?
Floor6 zhoushijay Posted 2007-04-29 04:44
高级用户 Posts 375 Credits 845
for's /r and /d commands seem to have been ignored for a long time, extra points, extra points

^ means that the following " is an ordinary character, not a symbol in the command
Floor7 dingamao Posted 2007-04-29 05:28
初级用户 Posts 47 Credits 118
Then wouldn't it become copy dos.txt ""?
I still don't quite understand how in specifies the folders here...?
Floor8 zhoushijay Posted 2007-04-29 05:52
高级用户 Posts 375 Credits 845
Because the value of %%i is a path with an extra " added at the end, for example d:\aa\bb\"
So "%%i becomes "d:\aa\bb\"
Floor9 dingamao Posted 2007-04-29 12:11
初级用户 Posts 47 Credits 118
Originally posted by zhoushijay at 2007-4-28 04:52 PM:
Because the value of %%i is a path with an extra " added at the end, for example d:\aa\bb\"
So "%%i becomes "d:\aa\bb\"

Looks like it's my fault for not making myself clear, I do understand this part. What I mean is...
Inside (^"), does ^ have any meaning besides indicating that what follows is an ordinary symbol?
I checked the usage of for /r, and it says that if the set contains only a single dot character, then it enumerates the directory tree~
So in this case, is ^ the so-called single dot character?
What exactly does single dot character mean?
Floor10 zhoushijay Posted 2007-04-30 00:06
高级用户 Posts 375 Credits 845
No, I think that "single dot" means when it's empty; the wording in the help command really is quite confusing.
Floor11 dingamao Posted 2007-04-30 02:15
初级用户 Posts 47 Credits 118
Oh~~~ if that's the case then it's easy to understand
Anyway, that "single dot character" in the help file really had me completely baffled!!!
Floor12 546474 Posted 2007-05-03 11:17
中级用户 Posts 123 Credits 247
The more you read the help, the more confused you get. You can only look at examples.
Floor13 skyhawk0012 Posted 2009-05-18 22:43
初级用户 Posts 22 Credits 22
Learning this, good stuff.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023