Unable to name the file to certain short names on Windows

Today I faced a peculiar issue, where I was trying to create a file named

PRN.java

It was a short code file and needed to be named with this name only.

2016-01-25_2308

The issue in this name is that PRN is a reserved keyword in the CMD execution shell.

Thus the file cannot be renamed to PRN.<extn> where <extn> can be any extension.

From MSDN:

Do not use the following reserved device names for the name of a file:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, PRN, 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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.