中国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-10 15:59
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS疑难解答 & 问题讨论 (解答室) » How to create a file under DOS
Printable Version  8,164 / 8
Floor1 xihaha Posted 2004-07-21 00:00
初级用户 Posts 12 Credits 148
What command is used to create a file? I'm asking for advice.
Floor2 Climbing Posted 2004-07-21 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
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.
Floor3 xihaha Posted 2004-07-21 00:00
初级用户 Posts 12 Credits 148
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?
Floor4 nre Posted 2004-07-21 00:00
银牌会员 Posts 361 Credits 1,210
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.
Floor5 Climbing Posted 2004-07-21 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
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.
Floor6 xihaha Posted 2004-07-22 00:00
初级用户 Posts 12 Credits 148
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?
Floor7 Climbing Posted 2004-07-22 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
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.
Floor8 xihaha Posted 2004-07-22 00:00
初级用户 Posts 12 Credits 148
Got it, thank you very much!
Floor9 lwha Posted 2010-07-11 21:59
新手上路 Posts 1 Credits 2
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.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023