Random thoughts: File naming conventions

First, a new column for the blog, if you can call anything here columns: Random thoughts.

Second, I had one. :D

It led me to researching the accepted wisdom for naming files. I have a very confused set of file name conventions I just haven’t been happy with for a while.

Almost everything I’ve read over the years says to avoid spaces in file names, so a while back I started naming folders and files like this:

c:\Writing\MySeries\MyBookTitle\MyBookTitle.docx

I did that not just because of having read a lot of advice saying to avoid spaces. I also had an instance where a file on my computer wouldn’t delete. I had to use the command prompt to get rid of it, and oh boy, was that a headache. So I don’t use spaces in file names in most instances anymore.

Some folders are like this though:

c:\Writing\MySeries\MyBookTitle\cover

In fact, all the subfolders inside my book folders are lowercase and use _ for spaces like_this, but all the folders outside those book folders are LikeThis or Like This.

I hate it.

It’s not very readable, and it’s definitely not consistent, although it is more readable than my first iteration:

c:\writing\myseries\mybooktitle\mybooktitle.docx

It was a nightmare with filenames like:

myseriesbookcovertemplate5x8.xcf

So I continually find myself looking for a better way, and yet internet searches never turn up anything I find particularly useful.

At some point, I read something that said to avoid hyphens because of cross OS compatibility. Underscores were the winner, but I can’t remember why, and so I started using _ whenever I needed a space.

I still don’t like spaces in file names because of the internet issue. And they’re ugly. Seeing %20 mixed into a long file name makes that filename look ridiculous and difficult to read.

So mostly I tried to stick with PascalCase.

PascalCase was a new term to me when I came across it. I thought I was using camel case, but apparently thisIsCamelCase, because it uses a lowercase first character.

Today I came across loads of people recommending ‐ instead of _ as a space replacement. So I’m back to wondering why hyphens aren’t a good idea in file names, because I still don’t remember why underscores were the winner, only I didn’t run across anyone talking about that issue this time around so I still don’t know!

And really, I think they’re mostly talking about filenames and folder names for the web, and that doesn’t matter much to me except in a very few specific instances (like book cover file names).

One reason I don’t like the dash as much as the underscore is because the dash isn’t as easy for me parse out as a space in a column of file names. But an underscore, if used in a hyperlink with an underline, is unreadable. You won’t even know it’s there sometimes.

:o

Really, this whole this is just one big annoying mess.

However, I have finally settled on a file naming convention this time, one that I’m pretty happy with, despite everything (and after two days of letting this obsession occupy brain space). Although to be honest it doesn’t solve the readability problem of PascalCase.

Maybe you don’t have trouble reading it, but I sure do!

Anyway, here’s what I came up with:

Stop using [ ] and other special characters in file names

Use hyphen instead of space when needed

MyFile-2016-01-09.txt

Dates like 20160109 are impossible for me to read, so I don’t use them.

Stick to title case for most things with no spaces

MyBookTitleNotes.docx
MySeries
MyBookTitlePbCover.xcf

When using 1–9, use 01–09

01-MyBookTitle

MyBookTitle root directory

MyBookTitle.docx
MyBookTitleMeta.docx
MyBookTitleNotes.txt

Folders (when needed)

backups
cover
ebooks
paperback
research

Folders are lowercase because they’re less distracting that way.

I know this is inconsistent with my other folders, but I actually do find them less distracting when they’re lowercase and they’re all one word names, and these particular folders are inside folders where I have to differentiate between a lot of similarly named files. I just won’t use two word file names here. If it ever does become necessary, I’ll just use a hyphen.

Files inside these folders

\cover\

MyBookTitleCover.xcf
MyBookTitlePbCover.xcf
my-book-title-1000.jpg

For jpg, png, gif, tif, use all lowercase, no space, no underscore, since these files are more likely to be used online.

\ebooks\

MyBookTitle.jutoh
MyBookTitle.epub

\paperback\

MyBookTitlePb.docx
MyBookTitlePb.pdf
MyBookTitlePbCover.pdf

Add a version number to the old file when replacing it so that it doesn’t overwrite old file in \backups\ folder if it is moved there later

MyBookTitlePb.docx (current)
MyBookTitlePb1.docx (oldest)
MyBookTitlePb2.docx (second oldest)

And that’s it. I did some cleanup to rename the files and my directories now look a lot better and everything is much more consistent. Now I’m satisfied, at least for a while. :D

Oh, and if you’re wondering how I changed all these names quickly and easily, I used a bulk renaming utility for the majority of the work. They’re very handy to have around!

Let me say that although I feel very satisfied with the changes I’ve made, I’m completely aware of the fact that spending two days on this was two days too many.

It’s procrastination, plain and simple, most likely to deal with the writer’s block I’ve got going on, and the only way to solve that is to get this obsession out of my system. Honestly, I almost believe these episodes are a way for my subconscious to keep my conscious thoughts occupied so it can work out whatever issues are going on with my writing. :)

Here’s hoping I’m correct about that and that when I finally put this obsession to bed, I’ll be ready to get past the current part in my book that has me completely stumped.