In Blog

In web development and bringing your business to the web (and thus a larger audience) some pre-planning and reviewing your workflow will go a long way. So, in this article we’re going to talk a little bit about file naming rules and conventions on different operating systems and why you should care.

The reality is, with any web development project, there is an extreme likelihood that not only will the team be sharing or passing files but that that flow will involve multiple operating systems.
Consider the team where the graphics people are using Macs, the web developers are using Windows for development and everything ultimately will run and be displayed from a Unix/Linux box.

“And why do I care?” you might ask. Well let’s further consider that most business websites are there to display and/or sell a collection of products. And displaying those products will involve a collection of images. Usually the image files are named for the product using some kind of product ID and many times those product IDs tend to be a simple numbering system. For example you might have products 0001, 0002, 0003, etc. with corresponding image files 0001.jpg, 0002.jpg, 0003.jpg, etc.

But let’s throw another wrinkle in the mix. Let’s say the images are the product, say, for a photographer’s website. And the photographer may innocently enough come up with a naming convention that helps them organize their files like maybe john|001.jpg, john|002.jpg, john|003.jpg. They’re all pictures of John and sequentially numbered. Makes sense, right?

Well let’s look at things to consider when sharing files across platforms

Legal characters or What’s in a name?

First each operating system (OS) uses a different file system. And each file system has its own set of rules as to what’s an allowable character to be used in a file name. See the table below for a summary.

file naming chart

Additional notes:

Mac OS 9 and OS X file names compatibility:
– Filenames preserves case but are not case sensitive.

Windows:
– Periods are allowed in file and directory names, but not as the last character. For example “letter.doc” is legal but “letterdoc.” is illegal file name.
– The following file names (names of PC ports) are not allowed: com1 thru com9, lpt1 thru lpt9, con, nul, and prn
– Filenames preserves case but are not case sensitive.

UNIX/Linux file names compatibility:
– Filenames preserves case and are case sensitive.

Of course you’ll notice that Windows is the most restrictive. So in our example above the files named john|001.jpg, john|002.jpg, etc. are not allowed on Windows and would cause you pain when trying to share across the network between your Mac and the Windows network server or a team member using a Windows machine.

If this is part or your set up (or that of your web development team) it’s best to stick to the most restrictive naming rules to avoid problems going forward when you have hundreds or possibly thousands of files to deal with. There are utilities out there that will convert Mac file names into legal Windows file names.

File Sorting or when is a zero not a zero?

This is an area where you can get lulled into a false sense of security of thinking you know how items will be displayed. And also an area where pre-planning of your work flow will help you avoid surprises.

One of the best things you can do in this area is use a naming convention that, if it includes numbers would also include alpha characters as well forcing the filename to be viewed as a string. And once you decide on the naming convention, stick to it.

The reason for this has mainly to do with the numeric sorts and the particular OS you may be working with. Even with Macs, OS 9 behaves differently than OS X in this regard.

With Mac OS X for example in sorting first comes space, then symbols (in no logical order), then numbers longer than 6 digits (treated as strings), then numbers up to 6 digits (treated as numbers), then letters. See the following example results

1000000
13316617
13333333
133333333
1333333333
9999999
99999999
999999999
002
02
133
1333
13333
88004
99999
130306_21
133333
999999

“002” is before “02” because they are numerically equal, so it compares
the strings, and 0 comes before 2. (likewise, “ e”, then “©”, then “ee”).

So the message here is again naming convention so that when you’re casually browsing through files on your machine you can be sure that they’ll be sorted the same way on a different machine with possibly different OS. For example even if your product IDs are all just numbers make sure any files (pictures, pdf documents, etc.) that correspond to your numbering scheme always have the same amount of digits (i.e. don’t start with 1 if you have 1200 products, start with 0001) and maybe even add a token to the beginning of the name. As in:

Product ID 14 has an associated .jpg file. Name it prod_0014.jpg. Or pictures of John while they reside in a folder name John add that token to the file name as well (e.g. john_0005.jpg).

In conclusion, when reviewing your work flow for a web project, keep in mind different people and different machine types will definitely be involved. So using conventions that meet the lowest common denominator can save you headaches in the long run and provide for a more flexible development environment.

Recommended Posts