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-12 13:36
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » How to copy all files in directory A to all first-level subdirectories of directory B? View 1,287 Replies 4
Original Poster Posted 2009-08-12 03:05 ·  中国 广东 深圳 电信
新手上路
Credits 11
Posts 5
Joined 2008-11-24 00:03
17-year member
UID 131901
Gender Male
Status Offline
How to copy all files in directory A

to all first-level subdirectories of directory B?
Floor 2 Posted 2009-09-07 03:17 ·  中国 四川 自贡 联通
新手上路
Credits 15
Posts 9
Joined 2007-11-13 16:16
18-year member
UID 102563
Gender Male
Status Offline
I'm a newbie too, haha... if I said something wrong, please don't mind. This is a question raised a long time ago, hehe, just giving the OP a bump:
for /l %i in ('dir/w/b B') do (copy %i a)
Floor 3 Posted 2009-09-07 04:30 ·  中国 广东 汕头 电信
新手上路
Credits 8
Posts 7
Joined 2009-06-15 12:46
17-year member
UID 147463
Gender Male
Status Offline
This is one approach; you'll need to change the specific paths for folders a and b yourself
@echo off
for /f "delims=" %%a in ('dir /ad /b b') do (
for /f "delims=" %%i in ('dir /a-d /b a') do (
copy "a\%%i" "b\%%a"
)
)
pause
Floor 4 Posted 2009-09-14 14:03 ·  中国 广东 广州 电信
初级用户
Credits 27
Posts 15
Joined 2009-09-13 11:28
16-year member
UID 151947
Gender Male
Status Offline
To all first-level subdirectories of directory B? Did I get that wrong or what?
Floor 5 Posted 2010-01-07 10:08 ·  中国 河南 郑州 电信
新手上路
Credits 6
Posts 3
Joined 2010-01-06 14:26
16-year member
UID 158093
Gender Male
Status Offline
Use xcopy
Forum Jump: