了解 FreeDOS 中的文件名和目录
FreeDOS

> 
> 了解如何在 FreeDOS 中创建，编辑和命名文件。
> 
> 
> 


![](/data/attachment/album/202103/16/094544qanrpbnlmltilump.jpg "Files in a folder")


开源操作系统 [FreeDOS](https://www.freedos.org/) 是一个久经考验的项目，可帮助用户玩复古游戏、更新固件、运行过时但受欢迎的应用以及研究操作系统设计。FreeDOS 提供了有关个人计算历史的见解（因为它实现了 80 年代初的事实上的操作系统），但是它是在现代环境中进行的。在本文中，我将使用 FreeDOS 来解释文件名和扩展名是如何发展的。


### 了解文件名和 ASCII 文本


FreeDOS 文件名遵循所谓的 *8.3 惯例*。这意味着所有的 FreeDOS 文件名都有两个部分，分别包含最多八个和三个字符。第一部分通常被称为*文件名*（这可能会让人有点困惑，因为文件名和文件扩展名的组合也被称为文件名）。这一部分可以有一个到八个字符。之后是*扩展名*，可以有零到三个字符。这两部分之间用一个点隔开。


文件名可以使用任何字母或数字。键盘上的许多其他字符也是允许的，但不是所有的字符。这是因为许多其他字符在 FreeDOS 中被指定了特殊用途。一些可以出现在 FreeDOS 文件名中的字符有：



```
~ ! @ # $ % ^ & ( ) _ - { } `

```

扩展 [ASCII](file:///Users/xingyuwang/develop/TranslateProject-wxy/translated/tech/tmp.2sISc4Tp3G#ASCII) 字符集中也有一些字符可以使用，例如 `�`。


在 FreeDOS 中具有特殊意义的字符，因此不能用于文件名中，包括：



```
* / + | \ = ? [ ] ; : " . < > ,

```

另外，你不能在 FreeDOS 文件名中使用空格。FreeDOS 控制台[使用空格将命令的与选项和参数分隔](https://opensource.com/article/21/2/set-your-path-freedos)。


FreeDOS 是*不区分大小写*的，所以不管你是使用大写字母还是小写字母都无所谓。所有的字母都会被转换为大写字母，所以无论你做什么，你的文件最终都会在名称中使用大写字母。


#### 文件扩展名


FreeDOS 中的文件不需要有扩展名，但文件扩展名确实有一些用途。某些文件扩展名在 FreeDOS 中有内置的含义，例如：


* **EXE**：可执行文件
* **COM**：命令文件
* **SYS**：系统文件
* **BAT**：批处理文件


特定的软件程序使用其他扩展名，或者你可以在创建文件时使用它们。这些扩展名没有绝对的文件关联，因此如果你使用 FreeDOS 的文字处理器，你的文件使用什么扩展名并不重要。如果你愿意，你可以发挥创意，将扩展名作为你的文件系统的一部分。例如，你可以用 `*.JAN`、`*.FEB`、`*.MAR`、`*.APR` 等等来命名你的备忘录。


### 编辑文件


FreeDOS 自带的 Edit 应用可以快速方便地进行文本编辑。它是一个简单的编辑器，沿屏幕顶部有一个菜单栏，可以方便地访问所有常用的功能（如复制、粘贴、保存等）。


![Editing in FreeDOS](/data/attachment/album/202103/16/094555vbiil6xelyvis2ds.jpg "Editing in FreeDOS")


正如你所期望的那样，还有很多其他的文本编辑器可以使用，包括小巧但用途广泛的 [e3 编辑器](https://opensource.com/article/20/12/e3-linux)。你可以在 GitLab 上找到各种各样的 [FreeDOS 应用](https://gitlab.com/FDOS/) 。


### 创建文件


你可以在 FreeDOS 中使用 `touch` 命令创建空文件。这个简单的工具可以更新文件的修改时间或创建一个新文件。



```
C:\>touch foo.txt
C:\>dir
FOO      TXT    0  01-12-2021 10:00a

```

你也可以直接从 FreeDOS 控制台创建文件，而不需要使用 Edit 文本编辑器。首先，使用 `copy` 命令将控制台中的输入（简称 `con`）复制到一个新的文件对象中。用 `Ctrl+Z` 终止输入，然后按**回车**键：



```
C:\>copy con test.txt
con => test.txt
This is a test file.
^Z

```

`Ctrl+Z` 字符在控制台中显示为 `^Z`。它并没有被复制到文件中，而是作为文件结束（EOF）的分隔符。换句话说，它告诉 FreeDOS 何时停止复制。这是一个很好的技巧，可以用来做快速的笔记或开始一个简单的文档，以便以后工作。


### 文件和 FreeDOS


FreeDOS 是开源的、免费的且 [易于安装](https://opensource.com/article/18/4/gentle-introduction-freedos)。探究 FreeDOS 如何处理文件，可以帮助你了解多年来计算的发展，不管你平时使用的是什么操作系统。启动 FreeDOS，开始探索现代复古计算吧！


*本文中的部分信息曾发表在 [DOS 课程 7：DOS 文件名；ASCII](https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-7-dos-filenames-ascii/) 中（CC BY-SA 4.0）。*




---


via: <https://opensource.com/article/21/3/files-freedos>


作者：[Kevin O'Brien](https://opensource.com/users/ahuka) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The open source operating system [FreeDOS](https://www.freedos.org/) is a tried-and-true project that helps users play retro games, update firmware, run outdated but beloved applications, and study operating system design. FreeDOS offers insights into the history of personal computing (because it implements the de facto operating system of the early '80s) but in a modern context. In this article, I'll use FreeDOS to explain how file names and extensions developed.

## Understanding file names and ASCII text


FreeDOS file names follow what is called the *8.3 convention*. This means that all FreeDOS file names have two parts that contain up to eight and three characters, respectively. The first part is often referred to as the *file name* (which can be a little confusing because the combination of the file name and the file extension is also called a file name). This part can have anywhere from one to eight characters in it. This is followed by the *extension*, which can have from zero to three characters. These two parts are separated by a dot.

File names can use any letter of the alphabet or any numeral. Many of the other characters found on a keyboard are also allowed, but not all of them. That's because many of these other characters have been assigned a special use in FreeDOS. Some of the characters that can appear in a FreeDOS file name are:

`~ ! @ # $ % ^ & ( ) _ - { } ``


There are also characters in the extended [ASCII](#ASCII) set that can be used, such as �.

Characters with a special meaning in FreeDOS that, therefore, cannot be used in file names include:

`*/ + | \ = ? [ ] ; : " . < > ,`


Also, you cannot use a space in a FreeDOS file name. The FreeDOS console [uses spaces to separate commands](https://opensource.com/article/21/2/set-your-path-freedos) from options and parameters.

FreeDOS is case *insensitive*, so it doesn't matter whether you use uppercase or lowercase letters. All letters are converted to uppercase, so your files end up with uppercase letters in the name, no matter what you do.

### File extensions

A file in FreeDOS isn't required to have an extension, but file extensions do have some uses. Certain file extensions have built-in meanings in FreeDOS, such as:

**EXE**: executable file**COM**: command file**SYS**: system file**BAT**: batch file

Specific software programs use other extensions, or you can use them when you create a file. These extensions have no absolute file associations, so if you use a FreeDOS word processor, it doesn't matter what extension you use for your files. You could get creative and use extensions as part of your filing system if you want. For instance, you could name your memos using *.JAN, *.FEB, *.MAR, *.APR, and so on.

## Editing files

FreeDOS comes with the Edit application for quick and easy text editing. It's a simple editor with a menu bar along the top of the screen for easy access to all the usual functions (such as copy, paste, save, and so on.)

![Editing in FreeDOS Editing in FreeDOS](https://opensource.com/sites/default/files/uploads/freedos_2_files-edit.jpg)

(Kevin O'Brien, CC BY-SA 4.0)

As you might expect, many other text editors are available, including the tiny but versatile [e3 editor](https://opensource.com/article/20/12/e3-linux). You can find a good variety of [FreeDOS applications](https://gitlab.com/FDOS/) on GitLab.

## Creating files

You can create empty files in FreeDOS using the `touch`

command. This simple utility updates a file's modification time or creates a new file:

```
C:\>touch foo.txt
C:\>dir
FOO TXT 0 01-12-2021 10:00a
```


You can also create a file directly from the FreeDOS console without using the Edit text editor. First, use the `copy`

command to copy input in the console (`con`

for short) into a new file object. Terminate input with **Ctrl**+**Z** followed by the **Return** or **Enter** key:

```
C:\>copy con test.txt
con => test.txt
This is a test file.
^Z
```


The **Ctrl**+**Z** character shows up in the console as `^Z`

. It isn't copied to the file but serves as an End of File (EOF) delimiter. In other words, it tells FreeDOS when to stop copying. This is a neat trick for making quick notes or starting a simple document to work on later.

## Files and FreeDOS

FreeDOS is open source, free, and [easy to install](https://opensource.com/article/18/4/gentle-introduction-freedos). Exploring how FreeDOS treats files can help you understand how computing has developed over the years, regardless of your usual operating system. Boot up FreeDOS and start exploring modern retro computing!

*Some of the information in this article was previously published in DOS lesson 7: DOS filenames; ASCII (CC BY-SA 4.0).*

## Comments are closed.