From the Editor

Andrew Pavey

Oh what a tangled web we weave (apologies to Sir Walter Scott). As computer operating systems have advanced the various players have had several goes at working out what is acceptable as a character in a filename and what isn't, and how long a filename can be. While not necessarily of great consequence in day to day life, such considerations become a major PITA when you start exchanging files, or sharing files between different operating systems.

Apple has been fairly consistent with a basic rule that you can use up to 31 characters for files and folders, 27 characters for a disk volume and the only character you can't use is ":". It's a good idea to avoid using a period "." to start a filename (this is a reserved indicator used by Apple to signify a "driver"). This holds for all Mac OS up to System 9. For OS X, you can use up to 255 characters for files or folders but still only 27 characters for a disk volume.

However if you want to exchange files with someone using another operating system you need to be aware of their rules and this gets more complicated. In MS-DOS 6.0 and before (Windows 3.x and before) a maximum of 12 characters are allowed. This is the so-called 8.3 format (8 characters, period, 3 characters, all upper case). Further, in MS-DOS 6.0 (which shipped with Windows 3.x) you can use alphabetic and numeric characters plus the punctuation marks ! # $ % & ( ) - ^ _ { } and ~ in both the base name and the extension of a FAT filename. Do not try to use the SPACE character. When Windows 95 shipped a few new characters were added like ' and @.
By default disks on modern PCs running Windows 95 or above allow a maximum of 255 characters, spaces and most other characters that are not allowed in a FAT system file name. / \ : * ? " < > | are not allowed under Windows XP. Unix, not surprisingly, is similar to OS X, ie up to 255 characters.

However things get a lot worse in that some Applications have their own rules, for example it is a bad idea to use / in a file name since it is illegal in MS Word (and lots of people will try and open your file in Word...). In addition although upper and lower case letters are both legal in Mac filenames, but you can not have two files in the same folder that are spelled the same like "SAM" and "Sam" and "sam" (but you can in Unix). You may occasionally encounter filenames which are not displayed the way you expect if you have used characters from outside the U.S. English character set in the name. These are generally due to problems in the way your operating system translates characters between the OEM and ANSI character sets. Using accented letters or any other character type using the option key ( like a bullet ) is also a very bad idea for filenames.

For cross platform compatibility keep your filenames to 31 characters or less if you are on UNIX or a PC and avoid putting / \ : * ? " < > | in a filename if you are on UNIX or a Macintosh. You can search for offending characters on a CD you are about to burn for PC users. It is also a good idea not to put more than one period in a filename and not to put one as the first or last character of the filename. Use capitalization with religious consistency or putting html files onto a UNIX server will result in dead links in a website. Putting a comma or semicolon in a filename could cause major problems under various circumstances on any platform when working with lists of filenames and thus should be avoided. A space or percent sign may be a little safer, but for the web a %20 will be automatically inserted in place of a space. If a user on one platform downloads part of a site hosted on another platform, links may break if spaces or % are used in names. For all filenames on a webserver I think it is easier to avoid the %20 which crops up in links when a space is encountered, by choosing to replace spaces with underscores.

It is impossible to make anything foolproof because fools are so ingenious

MACinations November 04

Next Article