Skip to main content

Section 1.1 File and Folder Names

Take a minute and look at some of the files and folders on your computer. What do the names look like?
Sorry, that probably wasn’t very clear. Specifically, I want you to see if there are spaces in your file and folder names. My guess is probably! Mine certainly had spaces before I learned more about computers and got involved in Git and the command line.
Take another look at some files/folders. What is your “capitalization scheme”? Is there a pattern? Do you name your files by what they contain? Do you have dates in your files? Do you have a group of files with something like “File First Draft”, “File Second Draft”, “File, revisions from colleague”, etc.? All of these can be problematic for computers and even more so for humans interacting with computers.
The following chunks go through my opinions on file naming conventions. But that’s what they are: opinions. Suggestions. Following them will make your life easier later on. But by all means, go ahead and ignore me and decide for yourself later if you want to make a change. I probably won’t pop up in your home and check your file names. Try not to get too lost with these; an extensive example will be provided at the end of the section.

Subsection 1.1.1 Naming Conventions

File Names With Revisions.

You might be familiar with this situation: You write one draft, get feedback, save a second draft as a new file, get feedback again, and finally make a new file with a final draft. Then, you decide to make modifications to that final draft which is saved as a new file, etc., etc.This is great until you realize that now you have way too many files for a single document. How do you know which one is real final draft? What if you open the wrong one and start editing? Now you have to edit all of the files to make them match.
Sure, a computer can handle that many files and doesn’t really care how many drafts or revisions you have. But more files take up more storage space and increases the chances of confusing you! How on earth can we solve this problem? It’s not like there’s a magic software that can keep track of all of our changes in a single file.
Ah, but there is! This magic software is called Git. Git specializes in version control which means that you do not have to worry about twelve drafts. Git keeps track of your revision history for you. If you are familiar with Google Docs, Git is very similar. Docs saves your changes and makes it easy to revert back to an old version if you change your mind on anything.
For now, don’t worry about Git; we will get there in Chapter 4. Just know that after reading this book, you won’t have to worry about excess drafts and should never have to save so many drafts again.

File Names With Dates.

Ok, this isn’t entirely problematic. But I never understood why dates in file names had to be so specific. Having years makes sense, maybe months. But days? Times? Seconds? Once you start getting that specific with dates and times, you run into the same issue as in File Names With Revisions. Dates and times just make your file names incredibly long, hard to read, and hard to use in the command line. Please try to avoid dates, other than years, perhaps.

Descriptive File Names.

File names should be descriptive! Furthermore, they should describe what the file actually contains/is about and not some random name. Probably most of your files are descriptive? That’s great! But what’s the catch? File names should also be short. Short, sweet, to the point, and also descriptive.
That’s pretty tricky, you might say. Sure, I respond, but you can take advantage of abbreviations and word-shortening tricks. For instance, suppose I had a file name like this:
Chapters3_4_Overview of Sampling and Simple Random Sampling (SRS).pdf
This is clearly descriptive. We know exactly what this PDF is about: it refers to chapters 3 and 4 of a textbook which is about sampling in general and digs into simple random sampling. But wow, it’s really long. On my computer, it shows up as
Chapters3_4_Overview of…SRS).pdf
Now do you know what this file contains? I don’t. Yes, it’s on chapters 3 and 4 but we are left hanging as to what the chapters are an overview of! Moreover, what does the random “SRS” mean at the end?
If it were me, I would rather name this file (based on the conventions discussed so far)
Ch3_4_Sampling and SRS.pdf
Wow! So much shorter. Do you still have an idea of what the file contains? Hopefully! “Ch” is usually accepted as an abbreviation for “Chapter” so it is clear that this file is over chapters 3 and 4. The subject of these chapters is sampling and simple random sampling (“SRS” is a widely-used abbreviation in statistics for simple random sampling).
File Naming Trick.
An easy way to shorten file names is to remove the vowels from words. The human brain is incredible in that it can determine what a word should be based on a small amount of context. Assuming the file above was in a folder pertaining to statistics, I could shorten it even more:
Ch3_4_Smplng and SRS.pdf
And we still know what it’s about!
A quick word of caution. Take care not to over-abbreviate. It may not be necessary to abbreviate every word. For instance, I wouldn’t change “you” to “y” or “gate” to “gt”. You may be confused later: does “gt” mean “gate”, “git”, “get”, “gut”, “agate”, etc., etc.?
Summary: keep your file names short and to the point. Describe what the file is (I wouldn’t name the file above “bananas.pdf”!).

File Names With Spaces.

If you only follow one convention in this section, this would be the one. This the most important for working with the command line. Spaces in file names increase the amount of typing you have to do and make it more difficult to understand what’s going on on the command line.
For instance, suppose I wanted to open the file we discussed earlier. On the command line, I would open the file like this (don’t worry about the commands, just notice what it looks like):
open 'Chapters3_4_Overview of Sampling and Simple Random Sampling (SRS).pdf'
I could also do it like this:
open Chapters3_4_Overview\ of\ Sampling\ and\ Simple\ Random\ Sampling\ (SRS).pdf
First, notice how long these titles are. That’s a lot to type! What you should really notice is that in the first example, the file is surrounded in quotes and in the second, there are a bunch of backslashes. For each file name with spaces, you have to either remember to enclose the entire name in quotes or to take the time to put a backslash before every space. It may not seem like too much of a hassle, but you will get annoyed with it pretty quickly. It also can cause setbacks inside code editors when you want to import or export files with spaces.
So what do we replace the spaces with?
Note 1.1.1.1. Alternative Naming Options.
Most computer programmers name their files using cases. There are five main cases:
snake_case
no capital letters, spaces are replaced with underscores (_)
kebab-case
no capital letters, spaces are replaced with hyphens (-)
camelCase
first word is lowercase, all consequent words are capitalized; spaces are removed
PascalCase
every word is capitalized, spaces are removed
UPPER_CASE_ SNAKE_CASE
every letter is capitalized, spaces are replaced with underscores (_)
See a Most Common Programming Case Types blog post 18  to get more details on these cases.
Personally, I use snake_case for file names and kebab-case for folder names, just to help me keep them separate and still easy to read. I also tend to name my files and folders with lowercase letters if I can.
Using the shortened file name above, I would use the following as my file name:
ch3_4_smplng_srs.pdf
Note that I got rid of the “and”. Cases are useful in that they make it easy to remove articles and prepositions which in turn helps us keep file names nice and short.
It is also important to keep your file names consistent. If I had another file about chapter 5 of this textbook which is about cluster sampling, let’s say, I would want to name it something like
ch5_clstr_smplng.pdf
Notice that the structure is the same as before: first I have “ch5” to represent the chapter number, then I describe the chapter with “clstr_smplng”. Like before, I use snake_case and I made sure to use the same abbreviation for “sampling” as I did before. Consistency is key for our own sanity and so we can quickly scan for the file we need.
It’s worth repeating once again. File names should not contain spaces. Files about related content should have a similar naming scheme.
Sorry, once more. This time, I’m going to yell. File names should not contain spaces.

A Quick Note on Folder Names.

Folder names should also follow all of the conventions above. This is a lot harder to get used to. I still feel like I’m breaking the Human Code of Folder Names everytime I ignore spaces and capital letters. For whatever reason, I’m fine with file names, but folder names just don’t feel right.
But too bad for me! I name my folders according to the conventions anyways. And you should too. (As I mentioned earlier, I use snake_case for files and kebab-case for folders. You might consider doing so as well; they are the two most popular cases.)

Subsection 1.1.2 Exploring File and Folder Naming Techniques

There were a lot of words in Subsection 1.1.1. Let’s make sense of them here with an extensive example. There will be some questions throughout the way. I encourage you to think about them and make sure you have understood the naming conventions above.
Suppose you work for Taylor Swift (wouldn’t that be cool!). She is super busy right now recording albums, writing songs, spending time with family and friends, and making TikToks and needs your help. She has all of her songs saved on her computer in folders which are divided up by one album per folder. She has asked you to help her rename her folders so that she still knows what each folder is, but follows proper naming conventions. Use your knowledge from above to help Taylor out.
Following is a list of her current folder names:
  • Taylor Swift
  • Taylor Swift (Deluxe)
  • Live From Clear Channel Stripped 2008
  • Fearless
  • Fearless (Platinum Edition)
  • The Taylor Swift Holiday Collection
  • Speak Now
  • Speak Now (Deluxe Edition)
  • Speak Now World Tour Live
  • Red
  • Red (Deluxe Edition)
  • 1989
  • 1989 (Deluxe Edition)
  • reputation
  • Lover
  • folklore
  • folklore (deluxe edtion)
  • folklore: the long pond studio sessions (from the Disney+ special) [deluxe edition]
  • evermore
  • evermore (deluxe version)
  • Fearless (Taylor’s Version)
  • Red (Taylor’s Version)
  • Midnights
  • Midnights (3am Edition)
  • Midnights (The Til Dawn Edition)
  • Speak Now (Taylor’s Version)
  • Unreleased Music
  • Singles
Wow! That’s a lot of albums! Complete the following tasks to make Taylor’s life a little easier for the future.
Please note that the answers to many of these exercises will vary depending on personal preferences. I will give answers depending on how I might approach the problem; they are certainly not the only answer you could have given.
(a)
Before we trying fixing a problem, let’s figure out what the problem is. What do you notice about these folder names? What about them is “incorrect”?
Solution.
The main thing that pops out to me are the spaces. Every multi-word folder name has a space. Secondly, some of the names are very long. Third, there is not much consistency. Some names are capitalized, others aren’t. There are clearly deluxe versions of albums but some say “deluxe”, others say “deluxe version”, and even others say “deluxe edition”.
The three here are the main issues; you may have thought of others. Great! I’m sure they are good observations.
(b)
Ok, we’ve identified a problem. How can we go about deciding what to do about it? You may already have some ideas, but stick with me here. Let’s not just dive in and start removing spaces and shortening folder names. Instead, let’s make a plan.
Identify some naming patterns. Are there any album names that are similar? Can you form any groups of names?
Solution.
There are probably a lot of patterns you could have noticed. I grouped folder names into
  1. Standard albums
  2. Deluxe albums
  3. Live albums
  4. Taylor’s Version albums
  5. Other
(c)
I am going to continue with the groups in the solution to Task 1.1.b. Feel free to branch off with your own groups or stick with me.
Now that we have groups, we can figure out how to name one of each group, then apply that naming style to all names in the group. Start with the standard albums, such as “Taylor Swift”. How can you change this name to stick with the conventions discussed above?
Solution.
Since there aren’t any special modifiers to this album (such as deluxe or live), I say we just keep its name, but write them in kebab-case. Therefore, “Taylor Swift” would become taylor-swift.
(d)
Apply the naming to scheme to all folders with “regular” album titles.
Solution.
The following names are the modified versions:
  • taylor-swift
  • fearless
  • speak-now
  • red
  • 1989
  • reputation
  • lover
  • folklore
  • evermore
  • midnights
(e)
Continue with the deluxe group. Identify patterns, change one name, then apply those changes to all the names in the group. Use your best judgement, but don’t stress about the “perfect” name.
Solution.
For the deluxe albums, the similarity is the word “deluxe”. I don’t bother with “edition” or “version”, “deluxe” is enough to convey the necessary information. I also would like to abbreviate “deluxe” to “dlx”. You could also choose to keep the full word, but since we can’t ask Taylor what she would prefer, I am sticking with the shorter. “dlx” gets the point across (this is a deluxe album) with 3 less characters. Following are my changes for the deluxe group. There is one outlier: the Fearless Platinum Edition. I am going to retain the “platinum” name since that is its true name.
  • taylor-swift-dlx
  • fearless-pltnm
  • speak-now-dlx
  • red-dlx
  • 1989-dlx
  • folklore-dlx
  • folklore-dsny-dlx
  • evermore-dlx
  • midnights-dlx-3am
  • midnights-dlx-dawn
(f)
Continue with the live group. Identify patterns, change one name, then apply those changes to all the names in the group. Use your best judgement, but don’t stress about the “perfect” name.
Solution.
There are only two in this group, but there could be more in the future. Let’s use “live” to differentiate these folders from the others. I am choosing to not use “lve” or “lv” because I think there are slightly ambiguous (it could mean “love”!).
  • clear-chnl-live
  • speak-now-live
(g)
Continue with the Taylor’s Version group. Identify patterns, change one name, then apply those changes to all the names in the group. Use your best judgement, but don’t stress about the “perfect” name.
Solution.
I am going to again use kebab-case and use “tv” to indicate that the album is a Taylor’s Version. This will help cut down on name length.
  • fearless-tv
  • red-tv
  • speak-now-tv
(h)
Continue with the other group. Identify patterns, change one name, then apply those changes to all the names in the group. Use your best judgement, but don’t stress about the “perfect” name.
Solution.
These are mostly up to you. They have no specific pattern, but I will still apply kebab-case and shorten the names.
  • holiday-clctn (I could even use holiday since there is only one holiday album)
  • unreleased
  • singles
I think that’s all of them! That may have seemed like a lot of work but I hope it was worthwhile. It should now be much easier for Taylor to navigate her folders and quickly know that album they contain.
If you feel like you have a good grasp of naming systems, feel free to skip Activity 1.2. If not, let’s explore file naming a little further. In Activity 1.1, we focused on Taylor’s folder names and since you helped her there, she is asking for your guidance with her file names as well.
We will focus on the folder that I renamed to be speak-now-dlx. A list of her current file names for these tracks follow. I should note that it is often helpful to prefix song names with their track position so that they stay in order when in a folder. We won’t remove those numbers. Also, “.wav” indicates that the song is a WAV file (see Section 1.2 for more). We should not remove these either as this could result in file loss or corruption.
  • 01 Mine.wav
  • 02 Sparks Fly.wav
  • 03 Back To December.wav
  • 04 Speak Now.wav
  • 05 Dear John.wav
  • 06 Mean.wav
  • 07 The Story Of Us.wav
  • 08 Never Grow Up.wav
  • 09 Enchanted.wav
  • 10 Better Than Revenge.wav
  • 11 Innocent.wav
  • 12 Haunted.wav
  • 13 Last Kiss.wav
  • 14 Long Live.wav
  • 15 Ours.wav
  • 16 If This Was A Movie.wav
  • 17 Superman.wav
  • 18 Back To December (Acoustic).wav
  • 19 Haunted (Acoustic Version).wav
  • 20 Mine (POP Mix).wav
Like before, complete the following tasks to make Taylor’s life a little easier for the future.
Again note that the answers to many of these exercises will vary depending on personal preferences. I will give answers depending on how I might approach the problem; these are not the only correct responses.
(a)
Before we trying fixing a problem, let’s figure out what the problem is. What do you notice about these file names? What about them is “incorrect”?
Solution.
The main thing that pops out to me are the spaces. Every multi-word file name has a space. Secondly, there are a few cases of non-consistency: Back To December says “Acoustic” whereas Haunted says “Acoustic Version”.
The two here are the main issues; you may have thought of others. Great! I’m sure they are good observations.
(b)
Ok, we’ve identified a problem. How can we go about deciding what to do about it? You may already have some ideas, but stick with me here. Let’s not just dive in and start removing spaces and shortening file names. Instead, let’s make a plan.
Identify some naming patterns. Are there any track names that are similar? Can you form any groups of names?
Solution.
There are probably a couple patterns you could have noticed. I grouped track names into
  1. “Regular” album tracks
  2. Acoustic tracks
  3. The last track
(c)
I am going to continue with the groups in the solution to Task 1.2.b. Feel free to branch off with your own groups or stick with me.
Now that we have groups, we can figure out how to name one of each group, then apply that naming style to all names in the group. Start with the “regular” tracks. How can you change these names to stick with the conventions discussed above?
Solution.
There isn’t much we can do here. I will write the names in snake_case which will remove the spaces and change every word to lowercase. Since we can’t ask Taylor for her preferences, it is up to you whether you want to abbreviate words or not. For the most part, I do not since most track names are short already.
  • 01_mine.wav
  • 02_sparks_fly.wav
  • 03_back_to_dec.wav
  • 04_speak_now.wav
  • 05_dear_john.wav
  • 06_mean.wav
  • 07_story_of_us.wav
  • 08_never_grow_up.wav
  • 09_enchanted.wav
  • 10_better_than_revenge.wav
  • 11_innocent.wav
  • 12_haunted.wav
  • 13_last_kiss.wav
  • 14_long_live.wav
  • 15_ours.wav
  • 16_if_this_was_movie.wav
  • 17_superman.wav
(d)
Apply the naming to scheme to all the acoustic tracks.
Solution.
I am choosing to abbreviate “acoustic” to “acoust”. Notice I used the same names as the regular tracks, but just appended “_acoust” at the end.
  • 18_back_to_dec_acoust.wav
  • 19_haunted_acoust.wav
(e)
Apply the naming to scheme to all the last track.
Solution.
I am choosing to abbreviate “POP Mix” to “pop_mix”. Notice I used the same name as the regular tracks, but just appended “_pop_mix” at the end.
  • 20_mine_pop_mix.wav
And that’s it! If you would like more practice, look up the track listing for her other albums and repeat this activity. It would be a great activity in consistency; for example, for the tracks on the Taylor’s Version albums, you would want to use the same naming scheme as in the folders. For me, I would say 02_red_tv.wav for “Red (Taylor’s Version)” and to any acoustic tracks, I would append _acoust.