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-06-25 05:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » To copy a specified folder in the current directory using DOS commands, you can use the `xcopy` command. For example, if the folder you want to copy is named `folder1`, and you want to copy it to the `backup` folder in the current directory, you can use the command: `xcopy folder1 backup /E /I` In this command, `/E` is used to copy directories and subdirectories, including empty ones. `/I` is used to assume that the destination is a directory if the source is more than one file or a directory. View 3,935 Replies 15
Original Poster Posted 2010-06-08 09:10 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
How to write code to copy the contents of a specified folder under the current directory to a disk? (Include empty files, do not copy the folder itself)
Floor 2 Posted 2010-06-08 10:20 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Floor 3 Posted 2010-06-08 11:04 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
@echo off
for /f "delims=ABC " %%i in ('find "ABC"') do xcopy /e %%i d:\
pause>nul
The folder I have is "ABC", and this doesn't work when written like this.
Floor 4 Posted 2010-06-08 16:38 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
What is this "for /f "delims=ABC " %%i in ('find "ABC"') do " for?
Floor 5 Posted 2010-06-09 13:58 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
Is it to copy the specified "ABC" folder in the folder where the batch file is located to the F: disk?
Floor 6 Posted 2010-06-09 18:26 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
Brother Hanye, please give me a hand.
Floor 7 Posted 2010-06-10 01:11 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Copy all text files (allowing files of size 0) in the abc directory in the current directory to the F drive
xcopy abc\*.txt f:\

And it is required to include files with hidden, system, and read-only attributes
xcopy /rh abc\*.txt f:\
Floor 8 Posted 2010-06-10 21:30 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
Why can't I copy files into the subfolder in the ABC folder?
Floor 9 Posted 2010-06-10 21:42 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
xcopy /e ABC I:\
pause Done
What does RH mean?
Floor 10 Posted 2010-06-10 23:06 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
The poster can take a look at the parameters of xcopy, xcopy /?
1. If you want to include subdirectories, use the /s parameter
2. To copy only folders but not files, use the /t parameter
3. To include empty directories, use the /e parameter
Floor 11 Posted 2010-06-11 14:51 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
Can Brother Han Ye use batch processing to achieve key clicks to connect to another BAT file? If possible, write an example for me to learn.
Floor 12 Posted 2010-06-11 15:33 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
I didn't understand what you meant...
Floor 13 Posted 2010-06-11 17:28 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
It's like there's a button on a software. For example, "OK", you click "OK" and you can open another BAT file. Can this function be realized?
Floor 14 Posted 2010-06-11 21:04 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
echo off
color 0a
cls
set a=12
set b=4
:reb
set /a a+=25
set /a b+=3
mode con: cols=%a% lines=%b%
echo ╭───╮ ╭───╮
echo │Format│ │Copy │
echo ╰───╯ ╰───╯
pause
For example, I can use the mouse to click "Format" to open the BAT file for formatting, and click "Copy" to open the BAT file for copying.
Floor 15 Posted 2010-06-12 11:17 ·  中国 广东 深圳 电信
初级用户
Credits 22
Posts 19
Joined 2009-07-12 02:46
16-year member
UID 149238
Gender Male
Status Offline
Isn't it impossible to achieve?
Forum Jump: