Name Files and Directories Like a Professional
If you're interested in an IT career, let's fix some bad habits before you start!
One of the first bad habits I need to break when I start teaching beginners is how they name their files and directories. Operating Systems like macOS are designed to be user-friendly, but some of the things these users do can cause problems in professional IT work. Let's establish some good habits from day one, you'll thank me later!
Rule 1: No Spaces!
Spaces in file and directory names might read nicer for regular users, but they can cause some serious problems.
In particular, when we work with command-line (terminal) commands, spaces have meaning. These tools often assume that a space indicates moving on to another part of a command, rather than part of the same filename. To work with files and directories with spaces in the name, we must add additional characters (called escape characters) or wrap them in quotation marks or other symbols. Another example is web development. Spaces are not valid in URLs and must be replaced with %20.
At best, dealing with spaces in file and directory names is annoying; at worst, they break commands.
When naming files and directories that have multiple "words", professionals usually use one of these options:
- Underscores: Underscores are the most common. Example:
my_project_file.py. - Hyphens: Hyphens are a popular choice in web files, though some tools will treat hyphens as subtraction operators. Example:
my-project-file.py. - camelCase: In some programming languages, there is no separator between words. The first character is lowercase, and each additional word uses a capital letter. Example:
myProjectFile.py. - PascalCase: Sometimes called proper case or upper camel case, each word starts with a capital letter, including the first character. Example:
MyProjectfile.py.
I don't want to count how much time I've lost in my career removing spaces and special characters from files that non-technical users send me!
Rule 2: Avoid Special Characters
In general, letters [a-z], numbers (0-9), and underscores (_) are the safest characters. Hyphens (-) are usually safe, but special characters like !@#$%^&*(){}[]:;, and so forth are risky to use. Depending on the tools and software you are using, special characters may cause problems:
Bad
My Project (v1).pyBudget$2024.csvTo-Do List.txt
Good
my_project_v1.pybudget_2024.csvtodo_list.txt
In general, I avoid special characters at all costs except in the rare cases where an application specifically requires them, which isn't common, but it does happen.
The dot (.) is a special case because it is used for hidden files and extensions. Obviously, we can use it in file and directory names for those purposes. Otherwise, avoid using it.
Rule 3: Be Descriptively Concise
There is an art to naming things. It's actually one of the sneakily difficult things about being a technology professional. We want to pick names that are descriptive enough to be clear to others, but not so long that they're a pain to type.
Bad
a.txtstuff.jsonthing1.py
Good
inventory.csvuser_manual.txt
Your future self and your coworkers will thank you for clear, descriptive names that explain what the file or directory is for.
Rule 4: Case Sensitivity
One thing beginners learn quickly when stepping into professional tech is that letter casing often matters. Hello is not the same as hello. But... sometimes it is. It depends on the software and tool you are using.
To save yourself pain and frustration, always assume that the casing matters.
When in doubt, use lowercase characters. It's the most common convention, especially on servers.
Rule 5: Dates and Sorting
Sometimes, it makes sense to include a date as part of a file or directory name, like a log file that contains information about a program running on a specific date or daily data files that contain reporting information.
It makes life a lot easier if the file name can be easily sorted by the date it references. Because of how numeric and alphabetic sorting work, you should always use year-month-day format for dates in file and directory names. For example, these files will not be sorted chronologically:
- report_1_5_2025.pdf
- report_12_3_2024.pdf
- report_2_10_2025.pdf
When sorting, each character is compared from left to right. The 2 in 12 comes after the underscore character when sorting, so the 2024 report would show up after the others when sorted in ascending order, which is incorrect.
Instead, we could name the files using year-month-day with leading zeros:
- report_2025_01_05.pdf
- report_2024_12_03.pdf
- report_2025_02_10.pdf
Now, the file names are consistent, and each character can be compared properly. The sorting will work!
Generally, the international standard date format is YYYY-MM-DD. If you were born and raised in the United States, sorry, but you're going to have to change the way you write dates!
Rule 6: Be Consistent!
Once you decide on a naming pattern in a project, stick to it! In professional software development, teams often have style guides that provide specific instructions for naming and organizing their project files and directories. Failing to follow these guides and being inconsistent are quick ways to annoy your peers.
In Conclusion
If you learn and apply these rules from the beginning, you will have a much easier time getting started learning IT skills. And, to be honest, it’d be a better technical world if non-professionals followed these rules too!