Reserved Names in Paths

Windows has several rules around naming files/folders/paths

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

One of these that I run into often enough to remember it’s a thing but not how to fix it is reserved names in paths CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

For more information, see Namespaces. You can’t rename the file using file explorer, cmd, powershell or anything else. The only way to do it was to call a specific API with powershell. Note this also requires the literal path prefix of \\?

[System.IO.File]::Move([file://C:/con.ucf]\\?\C:\con.ucf,”C:\co2n.ucf”)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...