Why cant a folder be named “CON” or “LPT1” in windows?

One of my close friend mayur has told me this trick that we cant rename text files and folders as “con”.I have been wondering over this for quite a long time and I think ,I have come up with a reason. Lets analyze :

For command prompt :

G:\>mkdir CON
The directory name is invalid.

G:\>mkdir LPT1
The directory name is invalid.

For windows explorer :

Even in the windows explorer, when you try to rename a file as “con” , the previous file name reappears.

Why is this so?

Inorder to find out why this doesn’t work we have to go back to the age of MS-DOS. Microsoft Disk Operating System (MS-DOS) is a command-line operating system that existed before the advent of GUI OS (Graphical User Interface). Everything from making ,renaming, deleting etc was done using commands. Some of the commands are…

COPY Copies one or more files to another location.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.

Let us look more closely to the COPY command. The COPY command usage is as follows:

COPY [options]  [options] 

In DOS everything is considered as files, even keyboard and printers. The filename for keyboard is given as “CON” and the printer names are given as “LPT1”, “LPT2” etc.. So inorder to copy something from keyboard (our input) the following command is used.

G:\>COPY CON mydata.txt
These lines come in mydata.txt and inorder to stop input press Ctrl+Z
^Z

G:\>COPY mydata.txt LPT1

So now you suppose that a folder or file named “con” could be created and you give a COPY CON command. What is DOS supposed to do? copy the CON file or use the keyboard console as input? Thus an ambiguity arises. So Microsoft has purposely disabled making of files or folders named CON / LPT1 / LPT2 etc. in order to remove this ambiguity.

Could you make a CON or LPT1 .. file on WINDOWS?

Found more invalid names? Let me know …..
Invalid Name List :

+ CON
+ LPT1, LPT2, LPT3, LPT4 … LPT9
+ PRN
+ NUL
+ COM1, COM2, COM3 …. COM9

####################################################

Did you find this article useful -

Filed under General. Posted by Abhishek and last updated on March 15, 2011.

Leave a Comment:

Your email address will not be published. Required fields are marked *

*

How can u use pic Cow giving Beer.
Its Bullshit man.
Change It.

Nice & Informative.

To create a ‘con’ folder.

Goto command prompt.
Type mkdir \con\

Note : Now you can’t delete this folder directly.

To delete a folder Goto command prompt.
Type rmdir \con\

Get Google Updates

Every Sunday, we send out "Google This Week" newsletter which covers all the latest and important updates from Google. First, we curate information from authentic and verified sources and then write the newsletter in an easy to understand format with images and summary for each update. View Sample ›

Join 9000+ subscribers following their favorite company in a simpler and easier way. Join Now ›