Windows: Why you cannot create any files or folders named CON, AUX, NUL, COM1 or LPT1
Info by Collin McNeil | Last update on 2022-12-30 | Created on 2017-05-17
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:
Name | Meaning |
CON | Console |
PRN | Printer |
AUX | Auxiliary Device, configurable |
NUL | Clear the output |
COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 | Serial Ports 1 to 9 (external connections, e.g. for devices or printers) |
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9 | Parallel 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.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
Rename File to its Folder Name
Tutorial | 0 Comments
MySQL: Line Breaks in MySQL
Tip | 0 Comments
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
Windows Batch Script: Computer Shutdown
Tutorial | 2 Comments
Google Tips: Search within documents of a specific file type (PDF, DOC, XLS, TXT, HTM etc)
Info | 0 Comments
Change uppercase and lowercase Writing of multiple Files
Tutorial | 0 Comments
MySQL: Rename Name of a Database
Tip | 1 Comment
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 article on askingbox.com. That’s how it’s done.