11.16.06

Forbidden file and folder names on Windows

Posted in Article, Windows at 11:17 am by Techie

Here’s an interesting experiment. On a Windows desktop, right-click on the desktop, and create a new Folder. Then, try renaming it ‘aux’. Can’t do it, right? There are certain restricted words that cannot be used to name folders or files, even though they use regular characters. You can’t even name it, say, ‘aux.test’. I came across this bug when editing files in CVS that were sourced on a Linux machine. I checked out the repository, but got errors for a folder named ‘aux’. I ended up doing work on a Linux machine to get around this, as there would be no way I would be able to work on the files there from Windows.

The following are reserved names, which cannot be assigned to a folder or file (normally):

  • CON
  • PRN
  • AUX
  • CLOCK$ (NT and older)
  • NUL
  • COM1
  • COM2
  • COM3
  • COM4
  • COM5
  • COM6
  • COM7
  • COM8
  • COM9
  • LPT1
  • LPT2
  • LPT3
  • LPT4
  • LPT5
  • LPT6
  • LPT7
  • LPT8
  • LPT9

It’s not impossible to create a file with that name, however. You just need to break out the old command line. From a Windows XP box, open up a command window (Start->Run, type cmd) and try:

md \\\\.\\c:\\aux

Congratulations, you’ve just created a folder named ‘aux’! You can even browse to it in Windows Explorer. To break down what the above does: the md stands for “make directory”. Specifying \\.\c:\aux means (in UNC format) on the local machine, volume C:, folder aux.

However, you still can’t delete it from Windows Explorer. To do that, you have to go back to the shell:

rd \\\\.\\c:\\aux

Aside from wowing your neighbors with your random geek knowledge, is there a practical use for this information? While I can’t think of any, it’s good to know to avoid using these, if doing cross-platform development. Do not use these names on a file on a Linux machine if they are going to be opened or edited by Windows users! This includes files and directories with those names but with an extension, such as aux.txt.

References:

8 Comments »

  1. Ritesh Aswal said,

    March 21, 2007 at 3:04 am

    just right click on rename and then press alt+255
    Give the name
    CON
    PRN
    AUX
    CLOCK$ (NT and older)
    NUL
    COM1
    COM2
    COM3
    COM4
    COM5
    COM6
    COM7
    COM8
    COM9
    LPT1
    LPT2
    LPT3
    LPT4
    LPT5
    LPT6
    LPT7
    LPT8
    LPT9

  2. Ritesh Aswal said,

    March 21, 2007 at 3:05 am

    It will work

  3. Alin Faur said,

    March 26, 2007 at 9:13 am

    Actually, the 255 ASCII code corresponds to a space, so the name won’t be “AUX”, but ” AUX”, which is different from the one wanted, so it is logic that it will allow you to do it.
    In fact, it’s the same as if you tiped “ZAUX” or “_AUX”, which means that it’s not included in the list mentioned above ;)

  4. Allewar said,

    April 13, 2009 at 7:09 pm

    I spent a whole afternoon trying to find the problem with copying files from a Mac computer to a windows file server. After many hours searching in files permissions, windows security preferences, and all sorts of sharing options, I narrowed the problem to some specific folders named ‘aux’. Then I googled it and found this page. :P

  5. Thor Whalen said,

    November 8, 2009 at 10:30 am

    Usefulness? Indeed! Imagine having a program that produces files, automatically choosing the name according to some useful scheme. Well bang! You will probably (if you’re processing a lot of data) stumble on a hard to catch funny bug.

    For example, if you’re dealling with IATAs, you’ll hit a problem as soon as you’re processing PRN (Pristina International Airport), CON (Concord Municipal Airport), etc.
    True story.

    Or say your files are taken from emails… I assure you, you’ll get a few con.rad@gmail.com, prn.me@whatever.org etc. And you’re screwed.

    Sigh! Windows!

  6. me said,

    November 19, 2009 at 10:37 am

    I was creating a tex folder “aux” and it did not work. I thought a program is blocking the path until I found this page.

  7. David said,

    March 4, 2010 at 5:37 pm

    There might be a use for this. If you create the folder from the command line as mentioned above, you will now have a seemingly undeleteable, unmovable, unrenameable folder. This can be useful if you don’t want an inexperienced user messing with your files.

    Also, if you want to create a file (not folder) with the name con, follow these steps:
    1. Create the file as you normally would
    2. From the command line, type the following, making sure to replace the path, as well as use the correct file extension:
    rename “\\.\c:\[path to file]” “con.txt”
    You now have a file with a forbidden name!

  8. Jason said,

    March 9, 2010 at 3:20 am

    Or just use Cygwin to bypass this silly restriction, especially if you’re a Linux user. :)

Leave a Comment

Bad Behavior has blocked 280 access attempts in the last 7 days.