3 3 Votes

Windows: Why you cannot create any files or folders named CON, AUX, NUL, COM1 or LPT1

Info by Computer Expert | 17/05/2017 at 09:58

Have you thought so far, that you can give your files or folders any name you want on Windows? This is not so! Just try to create a file named aux.doc or try to rename a file to con.txt. You will get the error message "The specified device name is invalid" and changing the name will not be possible. But why this behavior? And why this strange error message?

Some words or terms are reserved on the operating system Windows because they have a special meaning. Most of those reserved words are tracing back to DOS 1.0, a time at which you had to manage your computer via the command line entirely and file names were not allowed to be longer than 8 characters + 3 characters for the file extension (8.3 filenames).

At that time, you even had to control the output or the place to which something should be written by using the command line. For that, so-called magic filenames were implemented. You could use those filenames in the same way like standard files for example as the output of a text. For instance, PRN was the printer. So, if you specified "PRN" instead of a file name, instead of writing to the file, it was "written" to the printer and the desired text was printed.

Which names are not allowed to be used?

Other magic files were, for example, CON for the output on the screen or NUL for deleting the output. Here is the full list of all magic filenames:

NameMeaning
CONConsole
PRNPrinter
AUXAuxiliary Device, configurable
NULClear the output
COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9Serial Ports 1 to 9 (external connections, e.g. for devices or printers)
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9Parallel Ports 1 to 9 (external connections, e.g. for devices or printers)

On Windows, it is not allowed to use any of those terms as the name for a folder or a file. By the way, the file extension does not matter. The file "AUX" without extension is as forbidden as the files aux.txt, aux.doc or any other possible file extension.

Why are those names working in each folder?

The magic findings are working and implemented in each directory and folder. It does not matter whether you are directly accessing a directory or you are in an arbitrary sub directory. So, wouldn't it be sufficient to just call those file names only via a specific defined path? For example via C:\CON so that the folder C:\FOLDER\CON would not cause any conflict? Theoretically yes, but at the time, the magic file names were developed, the concept of folders and subfolders has not been implemented yet. So, the magic findings are a concept working in each folder and directory independent from the underlying file and directory structure.

Why are there magic filenames implemented still today?

You might think that DOS 1.0 is a long time ago, we are in a new century and no one is using those magic file names today anymore. Nevertheless, even in the newest versions of Windows, they are still there. What is the reason? Why has nobody abolished or removed this functionality? The reason is that the names are partially still used today. For example in batch files but also internally by different applications or the operating system itself.

ReplyPositiveNegative

About the Author

Avatar AuthorThe author has not added a short description to his profile yet.
Show Profile | Message

 

Related Topics

Rename File to its Folder Name
Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.