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-22 18:20
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » How to Use the copy Command View 5,574 Replies 13
Original Poster Posted 2006-07-02 15:04 ·  中国 四川 成都 联通
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Source: http://blogs.msdn.com/adioltean/archive/2005/02/25/380759.aspx
The tricks below aren't explicitly written out, but they're very useful in practice

1) To copy stuff from a directory to the current folder, you only need to specify the source folder:

y:\privates>copy C:\WINDOWS\system32\clients\twclient\x86
C:\WINDOWS\system32\clients\twclient\x86\twcli32.msi
1 file(s) copied.

2) Create a file without using an editor:

y:\privates>copy con sample.txt
This is a text file.
Another line...
^Z
1 file(s) copied.

y:\privates>type sample.txt
This is a text file.
Another line...

3) Create a zero-length file

C:\>copy nul empty.txt
1 file(s) copied.

C:\>dir empty.txt
Volume in drive C has no label.
Volume Serial Number is FCCD-E1D0

Directory of C:\

02/26/2005 10:38 PM 0 empty.txt
1 File(s) 0 bytes
0 Dir(s) 24,429,268,992 bytes free


4) Continue writing to the end of a txt file (append), note the /A parameter

y:\privates>copy /A abc.txt + con
abc.txt
con
BBB
^Z
1 file(s) copied.

y:\privates>copy /A abc.txt + con
abc.txt
con
CCC
^Z
1 file(s) copied.

y:\privates>type abc.txt
AAA
BBB
CCC

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 2 Posted 2006-07-02 22:15 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 466
Posts 237
Joined 2005-10-12 20:53
20-year member
UID 43413
Status Offline
Looks like this isn't really a new trick anymore
Floor 3 Posted 2006-09-20 10:53 ·  中国 安徽 合肥 电信
初级用户
Credits 52
Posts 17
Joined 2006-03-29 23:02
20-year member
UID 53022
Gender Male
From 安徽省合肥市
Status Offline
Learning
Floor 4 Posted 2006-09-30 01:26 ·  中国 内蒙古 赤峰 联通
新手上路
Credits 10
Posts 5
Joined 2006-09-29 23:29
19-year member
UID 64085
Status Offline
Newbie passing by
Floor 5 Posted 2007-04-25 10:59 ·  中国 湖北 黄冈 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
There really are a lot of uses for copy, like merging files, changing file dates, entering file contents on the screen without limits, and even deleting files.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Floor 6 Posted 2007-06-17 12:03 ·  中国 安徽 合肥 电信
中级用户
★★
Credits 334
Posts 154
Joined 2007-03-24 02:14
19-year member
UID 82713
Gender Male
Status Offline
Saved it, thanks.
Floor 7 Posted 2007-06-19 23:07 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
This doesn't really count as a new trick anymore.

The main thing is the use of input/output device files like con (keyboard), nul (empty), and files like prn, etc. By default they all output to the screen.

There are also applications of pipes like >, |, <, and also >> (append), etc.

Before Win95 came out, everyone who used computers knew this stuff, otherwise back then there was basically no way to use a PC.
Floor 8 Posted 2007-07-09 14:44 ·  中国 湖北 武汉 电信
初级用户
小子
Credits 76
Posts 26
Joined 2007-06-20 19:30
19-year member
UID 91913
Gender Male
Status Offline
Let me add one more, hehe
It's used to convert files with special encodings
copy a.doc a.txt
Back then I downloaded some command-line tools, and their help files were .doc files in some unknown encoding. Opening one of those 4K files took forever, but after using copy, the effect was very obvious
Floor 9 Posted 2007-09-16 00:21 ·  中国 江西 南昌 电信
中级用户
★★
Credits 245
Posts 123
Joined 2007-06-08 09:04
19-year member
UID 90636
Gender Female
Status Offline
Learned something, hehe
Floor 10 Posted 2007-09-20 12:30 ·  中国 天津 鹏博士宽带
新手上路
Credits 12
Posts 6
Joined 2007-09-12 20:35
18-year member
UID 97213
Gender Male
Status Offline
Not bad! Knows how to share his own knowledge with others!! Better than those guys who just put others down~~~ all talk and no action!!
Floor 11 Posted 2007-10-15 10:45 ·  中国 河南 安阳 联通
初级用户
Credits 88
Posts 45
Joined 2005-09-07 22:43
20-year member
UID 42336
Gender Male
Status Offline
This can all be done with echo plus the double redirection operator too
Floor 12 Posted 2008-05-03 11:37 ·  中国 陕西 榆林 电信
新手上路
Credits 13
Posts 9
Joined 2008-05-03 09:07
18-year member
UID 117616
Gender Male
From 陕西/榆林/绥德
Status Offline
Just passing through
Floor 13 Posted 2008-07-03 16:52 ·  中国 湖北 黄石 电信
初级用户
★★
Credits 108
Posts 56
Joined 2007-05-07 16:00
19-year member
UID 87758
Gender Male
Status Offline
Learning
Floor 14 Posted 2009-11-10 20:49 ·  中国 福建 宁德 电信
初级用户
Credits 24
Posts 13
Joined 2008-12-15 22:06
17-year member
UID 133989
Gender Male
Status Offline
Newbie learned something~
Forum Jump: