If you are in the IT business long enough, the topic of the best way to name a file or directory comes up. This is can be a contentious topic, but I think that it is wise to adopt some form of naming rules to keep some sanity in the files you or your team can live with. I did some quick looking around and collected some general rules to strive for when naming files or directories.
Some of these rules may be obvious, and some are contradictory. Here is what I found in my search.
- Avoid spaces. Use dashes or CamelCase instead. Possibly use underscores.
- Avoid special characters. ( \ / : * ? ” < > | [ ] & $ , . ~ @ # % )
- Avoid upper case.
- Assume case sensitivity, but dont depend on it. Some OSs support it, others dont.
- Use the format “YYYY-mm-dd-HH-MM-SS” or “YYYY-mm-dd_HH-MM-SS” when including dates.
- Use the same naming convention for similar files. This will keep similar files grouped together when sorted.
- Be brief yet descriptive as possible. Avoid confusing abbreviations.
- Avoid excessive meta data in filenames.
- Limit filenames to 255 characters, the shorter the better.
- Omit words such as “a”, “of”, “the”, “in”, “from”, etc. when possible.
- Avoid including the file type in the filename description.
- Use a period to separate the base file name from the extension.
- Do not use the following Windows reserved names for the name of a file: 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.
- Do not end a file or directory name with a space or a period.
- Be consistent.