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 12:00
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to create a file under DOS View 7,865 Replies 8
Original Poster Posted 2004-07-21 00:00 ·  中国 湖北 武汉 鹏博士宽带
初级用户
Credits 148
Posts 12
Joined 2004-07-17 00:00
21-year member
UID 28572
Gender Male
Status Offline
What command is used to create a file? I'm asking for advice.
Floor 2 Posted 2004-07-21 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
In DOS, the command to create a directory is the `md` command. You must be asking if there is a command used to create a file, just like the function of creating a new text file (or a new Word file) in Windows. Well, actually, there isn't such a command in DOS. But there are many ways to create a new file in DOS. For example, you can copy another file over (using `copy`), or you can use the Edit command to edit a file and then save it, or you can use the pipe method like `dir > newfile.ext` to create a file. In short, in DOS, to create a new file, you need to determine the content of the file first (even if it's empty), and then you can save it as a file. This is different from Windows. In Windows, you can first create an empty file and then enter content, but in DOS, you have content first and then the file.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2004-07-21 00:00 ·  中国 湖北 武汉 鹏博士宽带
初级用户
Credits 148
Posts 12
Joined 2004-07-17 00:00
21-year member
UID 28572
Gender Male
Status Offline
That's the meaning. I got inspiration after reading it. Thanks. Also, I would like to ask: Can you edit any file, such as EXE, BAT, TXT, etc. by COPY, and then save it as the file type you need, like saving an EXE as TXT?
Floor 4 Posted 2004-07-21 00:00 ·  中国 北京 联通
银牌会员
★★★
nre
Credits 1,210
Posts 361
Joined 2002-12-28 00:00
23-year member
UID 629
Gender Male
Status Offline
This doesn't work. The file name is just an identifier. What type this file actually is depends on the content of the file itself. Just like a person's name, no matter how you change the name, the person's attributes don't change at all.

Teamwork !
Floor 5 Posted 2004-07-21 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Files are divided into two types: text files and binary files. Text files can be copied over and then edited with Edit, but although binary files can be opened with Edit, the content is all garbled and cannot be edited in principle. As the person upstairs said, filenames are named by the people operating the computer, but the content of the file does not change with the change of the filename. We need to give appropriate names to files according to their content, but we cannot imagine that the content of the file changes with the change of the name.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 6 Posted 2004-07-22 00:00 ·  中国 湖北 武汉 鹏博士宽带
初级用户
Credits 148
Posts 12
Joined 2004-07-17 00:00
21-year member
UID 28572
Gender Male
Status Offline
Thanks. I mean, for example, if you want to create a text file, COPY an EXE file, delete all its contents, and enter text, then is it just a text file? If you want to create a HELP file by yourself, how to create it? Because my 98 boot disk doesn't have this file, and there's no such type. How to operate the dir > newfile.ext pipeline to create a file, and how to define the file type, can you explain it?
Floor 7 Posted 2004-07-22 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
In principle, it can be like this, but there is absolutely no need to be so troublesome. Just use Edit to enter the content of the text file you want to create and then save it. It's just like directly using Notepad to enter the file content and then save it. Regarding pipeline operations, it is recommended that you study the basic knowledge of DOS carefully.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 8 Posted 2004-07-22 00:00 ·  中国 湖北 武汉 鹏博士宽带
初级用户
Credits 148
Posts 12
Joined 2004-07-17 00:00
21-year member
UID 28572
Gender Male
Status Offline
Got it, thank you very much!
Floor 9 Posted 2010-07-11 21:59 ·  中国 河北 衡水 桃城区 联通
新手上路
Credits 2
Posts 1
Joined 2009-10-19 20:42
16-year member
UID 153349
Gender Male
Status Offline
There are many kinds.
1.------------------------------------
cd.>c:\New 1.txt
rem.>c:\New 1.txt
type nul>c:\New 1.txt

2.------------------------------------
c:>c:\New 1.txt

3.------------------------------------
copy nul c:\New 1.txt
echo. >c:\New 1.txt

The ones listed in 1 are relatively perfect. The ones in 2 and 3 occasionally produce blank lines or garbled codes. The ones that frequently produce text and garbled codes in the newly created files are not listed here. Please choose freely.
Forum Jump: