What is the meaning of the "con","prn" and "nul" folders and what are they used for..
Pls I need a clear explanation.

Dani AI

Generated

Short answer: those names are legacy device names (console, printer, null, serial/parallel ports) left over from CP/M/DOS and still reserved by Windows. As pointed out they are device names; as noted they are useful for redirection — but you cannot use them as ordinary file or folder names in normal Windows Explorer/Explorer APIs. (en.wikipedia.org)

What is reserved (summary): CON, PRN, AUX, NUL, COM1..COM9, LPT1..LPT9 (and a few related aliases). These are treated specially by the OS (case‑insensitive, reserved in every directory, and you should avoid using them even with extensions). The official Microsoft docs list these reserved names and warn about using them. (learn.microsoft.com)

Practical notes / troubleshooting: if you stumble on a real file or folder named e.g. "con" (created from another OS, by a tool, or via special tricks) Explorer and cmd will refuse normal access. Two common workarounds that avoid harming data:

  • Use a POSIX environment (WSL, Git Bash, MSYS2) and remove the entry there (POSIX tools treat the name as a normal filename). (blog.lucaslifes.com)
  • Use Windows verbatim/device paths to address the item (the Win32 verbatim/device prefixes bypass normal path parsing), e.g. the extended path/device namespace; these techniques can also create or remove such names but must be used with caution. For low‑level fixes see the Microsoft naming/namespace docs and PowerShell examples that use a literal path. (kiwids.me)

Advice: treat these as reserved by design. Validate or sanitize user/supplied filenames (reject those tokens) and avoid creating files or folders with those names — doing otherwise can leave you with objects that are awkward to manage on Windows. (learn.microsoft.com)

Recommended Answers

All 2 Replies

These are devices that appeared long ago in CP/M and DOS days. It's that simple. These are devices. Some are real such as the console and printer but nul is just that. Send something to nul and it goes there never to return.

I take it you are very new to the internet. Such devices have prior answers. Did anyone show you how to google or research yet?

They can be udeful when working from the command line. con is the console device. cat lists the contents of a file to the console. If you cat and redirect input from the console then cat will display everything you type. Not a useful example but still an example.

D:\>cat < con
abc
abc
def
def

nul is the null device and is useful for suppressing output. This can be useful in cmd files where you want to minimize output.

D:\>echo "hello"
"hello"

D:\>echo "hello" > nul

D:\>
commented: Very udeful reply. +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.