23
Why you can't name a file "CON" in Windows?
❓ Did you know you can’t name a file “Con” in Windows
If you’re running a Windows machine, try it right now. Go to File Explorer -> create a new folder -> name it "Con"
Did it work? Now try with "PRN", "AUX" or "NUL". What did you get?
Probably this 👇
The system will not let you do it.
Con is an English word, and there are a few human names like Connor who goes by the nickname 'Con'. So if you’re trying to save a photo of one of them using their nickname on Windows, you will not able to.
In fact, the system won't let you name a file or folder CON
, AUX
, PRN
, LST
, COM0
to COM9
, LPT0
to LPT9
, or NUL
.
The reason for that goes back to MS-DOS, one of the oldest command lines from the 80s. In MS-DOS, all those words that are mentioned above are the names of device files.
They were a quick and clever way of letting programs on a computer interact with other hardware like printers, keyboards, and basically anything that you can plug in. Rather than every program having to learn to communicate with every possible device, that job was given to a "device driver".
This was done so that programmers didn’t have to worry about how every single type of hardware device like printers worked. Instead, they could reuse code that they already had for reading and writing files from and to the printer. They would just have to save whatever they wanted to print to this "device file".
This means that even when a new printer came out with new features in it and if the manufacturer would bundle a new driver with it, all the old programs would still work, in the same way as they always did, and the driver would deal with the dirty stuff.
If you type "dir" in your windows terminal, you’d get a listing on the screen of whatever files were in the current directory or folder. Typing "dir", adding a redirect symbol(>) after that, and mentioning a file name at last, would then save the listing on that file instead of the listing going to the screen.
But if you tried to save it to a file called "LPT1", the system would spot that file name, and instead of going to the hard disk, your list will be sent to the device driver for the parallel port, the one that was labeled LPT1 on the back of your computer. The place where you have a printer plugged in. So even knowing anything about how the parallel port or printer worked, you could just print stuffs.
Windows 10 probably don't use parallel port now but the reason why these reserved words still exist till now is because of backward compatibility.
Windows 10 retains code from the days of Windows 3.1, and Windows 3.1 was created with MS-DOS as basic, so was Windows 95. With Windows NT this did not happen, but still, Microsoft wanted it to be compatible with Windows 95, and Windows 10 is still partly based on Windows NT. So those were the reserved words in MS-DOS in the 80s and they still continue to be reserved words in Windows in 2021
Almost no one may use a parallel port to connect a printer anymore, but Microsoft chooses to continue to support extremely old software and devices to this day.
In this article, we saw why you can't name a file or a folder "Con" in Windows.
In the early times of MS-DOS, computers were basically a black screen with text and nothing else. So everything worked by writing orders. For a program to interact with other things, such as a printer, a command had to be written using a text file or “device file” that would interact with a driver.
Depending on the device, it has a name reserved. For example, the parallel ports that printers used to connect to use LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. The serial ports has reserved COM from COM1 to COM9. "CON" represents the console etc.
To this day those device names are reserved so that you cannot create usable files or folders with them. If back then you tried to do something like creating a file called LPT1.txt, what you were going to do was send it to the printer or something like that and that’s why they were blocked.
Hope you learned something new today!
Thanks for reading :))
Checkout ▶ HTML To React: The Ultimate Guide
This ebook is a comprehensive guide that teaches you everything you need to know to be a web developer through a ton of easy-to-understand examples and proven roadmaps
It contains 👇
✅ Straight to the point explanations
✅ Simple code examples
✅ 50+ Interesting project ideas
✅ 3 Checklists of secret resources
✅ A Bonus Interview prep
You can even check out a free sample from this book
and here's the link to the complete book, if you want to buy it for yourself
👇
23