Convenient way to name files in Linux

audiofilenamesfiles

I've noticed that a lot of people involved in Linux (like tutorials and guides) tend to name files omitting spaces and replacing them with the character "_" and I would like to know if there's a reason to do so. Also I want to know what other characters should be avoided when naming files. What about capital letters? I've seen a preference for lowercase letters.

As a last query, what would be the best way to name my songs in Linux. For example, I got a lot of files in the format: track. artist name - song name.mp3, like 01. Crystal Castles - Untrust Us.mp3. Should I change the format to something like track._artist_name_-_song_name.mp3 as in 01._Crystal_Castles_-_Untrust_Us.mp3I would like to know your opinion on this matter.

Best Answer

Technically speaking, the only characters that are explicitly disallowed are / and \0 (the NUL byte) since these have special meanings.

However, there are some conventions that people tend to use for convenience's sake. For example, you noticed that people prefer not to use spaces and instead use _. This is because a spaces are word delimiters on *nix command-lines. As a result, if you use a space in a file-name, you must either quote the file name or escape each space (with a \) for the name to be recognized correctly as a single entity. Though you can use spaces in filenames, the extra effort deters many people from doing so.

Additionally, capital letters are avoided (by some), probably because it takes more effort to type those file names—afterall, pressing Shift is pretty hard!

Your question of "What is the best convention?" is difficult to answer; as with many issues, under *nix, the best solution is what works best for you.

Personally, I keep my audio files in a file hierarchy (~/Music/<Artist>/<Album>/) and each track name like so: ## - <Track Name>.ext.

Related Question