中国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-07 13:44
48,040 topics / 350,125 posts / today 0 new / 48,252 members
DOS学习入门 & 精彩文章 (教学室) » How to Use the copy Command
Printable Version  5,697 / 13
Floor1 electronixtar Posted 2006-07-02 15:04
铂金会员 Posts 2,672 Credits 7,493
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
Floor2 Scott0902 Posted 2006-07-02 22:15
中级用户 Posts 237 Credits 466
Looks like this isn't really a new trick anymore
Floor3 tom861221 Posted 2006-09-20 10:53
初级用户 Posts 17 Credits 52 From 安徽省合肥市
Learning
Floor4 lllenxue Posted 2006-09-30 01:26
新手上路 Posts 5 Credits 10
Newbie passing by
Floor5 6622186 Posted 2007-04-25 10:59
高级用户 Posts 411 Credits 894
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.
Floor6 wangmeng052 Posted 2007-06-17 12:03
中级用户 Posts 154 Credits 334
Saved it, thanks.
Floor7 duanml Posted 2007-06-19 23:07
中级用户 Posts 112 Credits 231
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.
Floor8 tclgb Posted 2007-07-09 14:44
初级用户 Posts 26 Credits 76
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
Floor9 hxwxyz Posted 2007-09-16 00:21
中级用户 Posts 123 Credits 245
Learned something, hehe
Floor10 zlongzhao Posted 2007-09-20 12:30
新手上路 Posts 6 Credits 12
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!!
Floor11 zlgs Posted 2007-10-15 10:45
初级用户 Posts 45 Credits 88
This can all be done with echo plus the double redirection operator too
Floor12 m5891662l Posted 2008-05-03 11:37
新手上路 Posts 9 Credits 13 From 陕西/榆林/绥德
Just passing through
Floor13 xue0808 Posted 2008-07-03 16:52
初级用户 Posts 56 Credits 108
Learning
Floor14 systeminfo Posted 2009-11-10 20:49
初级用户 Posts 13 Credits 24
Newbie learned something~
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023