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-11 20:43
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How do I copy a file into every subdirectory? View 1,237 Replies 12
Original Poster Posted 2007-04-29 01:00 ·  中国 广东 电信
初级用户
Credits 118
Posts 47
Joined 2007-03-10 16:00
19-year member
UID 81323
Gender Male
Status Offline
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 :(
Floor 2 Posted 2007-04-29 01:08 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Search ;

This kind of question has been discussed way too many times
Floor 3 Posted 2007-04-29 01:15 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
The OP can try thinking about it like this:
Use dir's /s parameter together with a for loop.
Floor 4 Posted 2007-04-29 02:25 ·  中国 广东 广州 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
lxmxn +4 2007-04-29 03:41
zhoushijay +4 2007-04-29 04:42
Floor 5 Posted 2007-04-29 02:42 ·  中国 广东 佛山 电信
初级用户
Credits 118
Posts 47
Joined 2007-03-10 16:00
19-year member
UID 81323
Gender Male
Status Offline
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?
Floor 6 Posted 2007-04-29 04:44 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
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
Floor 7 Posted 2007-04-29 05:28 ·  中国 广东 广州 电信
初级用户
Credits 118
Posts 47
Joined 2007-03-10 16:00
19-year member
UID 81323
Gender Male
Status Offline
Then wouldn't it become copy dos.txt ""?
I still don't quite understand how in specifies the folders here...?
Floor 8 Posted 2007-04-29 05:52 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
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\"
Floor 9 Posted 2007-04-29 12:11 ·  中国 广东 电信
初级用户
Credits 118
Posts 47
Joined 2007-03-10 16:00
19-year member
UID 81323
Gender Male
Status Offline
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?
Floor 10 Posted 2007-04-30 00:06 ·  中国 新疆 乌鲁木齐 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
No, I think that "single dot" means when it's empty; the wording in the help command really is quite confusing.
Floor 11 Posted 2007-04-30 02:15 ·  中国 广东 深圳 润迅通信集团有限公司
初级用户
Credits 118
Posts 47
Joined 2007-03-10 16:00
19-year member
UID 81323
Gender Male
Status Offline
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!!!
Floor 12 Posted 2007-05-03 11:17 ·  中国 安徽 芜湖 电信
中级用户
★★
Credits 247
Posts 123
Joined 2007-04-17 06:29
19-year member
UID 85468
Gender Male
Status Offline
The more you read the help, the more confused you get. You can only look at examples.
Floor 13 Posted 2009-05-18 22:43 ·  中国 江苏 泰州 电信
初级用户
Credits 22
Posts 22
Joined 2005-10-24 21:39
20-year member
UID 44006
Status Offline
Learning this, good stuff.
Forum Jump: