“Illegal” in the rather peremptory manner of “computer-speak” that is..

Earlier this week, a client and I had problems transferring some data from an Apple Mac to a USB pen drive (or “memory stick”, if you insist on using that misnomer) prior to copying it onto a shiny new Windows 8 laptop.

Sopranos - Illegal Character?The copying process kept encountering forward slash and backslash characters contained within the names of files (eg a file’s name might have been “accounts at 31/12/2013”). Every time this happened the copying process just stopped dead with an error message. The problem arises because forward slash and backslash characters are permitted in the file system used by the Apple Mac operating system, but not in either of the two filing systems used by Windows (FAT and NTFS). The USB pen drive had been prepared (“formatted”) to use a Windows-friendly filing system and it just wasn’t going to accept files with “illegal characters”.

Question Mark

Another illegal character. It was very very hard finding images for this post!

What we did about it was to use the Mac’s spotlight (search) feature to list all of the files that included the offending characters and the client then manually changed all the filenames while I had more fun setting up the new laptop. There were a couple of hundred or so file names to change. Had there been thousands, I would have searched online for a utility (program) to automate the process.

How do you avoid such problems? In general, these things are only likely to crop up if you try to move something from a Mac system to a Windows system where there are characters that are illegal in Windows systems. If you think that there’s any chance that you might want to move or copy files in this way then don’t use the characters listed below in a Mac system, even though they are legal. You can’t fall foul of these rules while you stay within one operating system because that operating system won’t let you use a character that is illegal in that operating system’s filing system. The problem is only going to crop up if you transfer files between filing systems.

Mac Illegal Characters

  • :
  • Yep, that’s it. The only illegal character in OS9 and OSX is the colon. Further to that, though, you can’t use a full stop (aka a dot or a period) as the first character in a file name, as this would designate the file as hidden.
  • File and folder names can be up to 255 characters long in the current operating system (OSX), but only 31 characters in OS9.

Windows Illegal Characters

  • / ? < > \ : * | ”^
  • Actually, you can use the caret (“^”) in NTFS, but steer clear of it if you are likely to copy anything to a pen drive as it might be formatted as FAT.
  • I would also recommend steering clear of using a ~ (tilde) as Microsoft Office programs use this for a temporary version of the data file you have open (with a tilde as the first character). By the by, these temporary files are deleted automatically if you close the file correctly. If you find loads of Word documents or Excel spreadsheets on your hard drive whose names beging with a “~” then it’s a sign that you’ve not been closing your files and Office programs properly. As long as the programs are not currently running, it’s safe to delete such files.
  • File and folder names can be up to 255 characters long in FAT and 256 in NTFS.
  • Also, there are some “reserved names” in Windows that have been used to designate specific things (serial and parallel ports, if you must know). So, you can’t use the following as file or folder names – com1, com2, com3, com4, com5, com6, com7, com8, com9, lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, lpt9, con, nul, and prn.

We’ve only been looking at file names here. Just because a file can be transferred between a Mac and a PC (in either direction) without falling foul of these naming rules doesn’t mean that the receiving system will be able to deal properly with the file. Whether you can actually open and read a file created on another system is dependent on having a program capable of understanding the contents of the file. You can rely on common types of files (such as pdf files and image files) being happy on any system, but proprietory files (eg those produced by accounts systems) may need some “conversion” or “importing” process. Such processes – if they exist – would be found within the program that is going to use the file.

Ever wondered how Windows knows which program to open for a particular data file?

If you double-click on a file in Windows Explorer (or, indeed, on the name of an email attachment or any other hyperlinked file), Windows will open the program that is normally used to open that file. That program will then open the file. This is known as “file association”: the file that you wish to open is associated with a particular program.

The way this happens is that all filenames have a full-stop at the end of the name and then a number of characters (letters and/or numbers) after the full-stop. These characters after the full-stop are the “file extension” and each file extension is “associated” (on that computer) with a particular program. You can learn more about file extensions here. Some examples of file extensions are:

  • fred.pdf – this filename has an extension of “.pdf”. Pdf files are normally associated with either Adobe Reader or Adobe Acrobat. In this case the “pdf” stands for “Portable Document Format”.
  • cv.docx – the extension is “.docx” and this is associated with Microsoft Word 2007 or 2010. Documents created by previous versions of Word have “.doc” as the file extension.
  • family.jpg – the extension is “.jpg”, indicating that this is a particular type of image. Jpg files could be associated with one of many different programs that handle images.

If the file extension is “.exe” or “.com” then the file is not a data file, but a program. Double-clicking on a program will start (launch) it.

When you open Windows Explorer (usually by double-clicking on the “Computer” or “My Computer” option), you are presented with lists of files that may or may not show the extension. The figure below shows the same file listing with the extensions hidden and then with the extensions displayed.

Windows Explorer views of files with extensions hidden and visible

Admittedly, I am helped in the above figures by the fact that the program on my computer that is associated with images files (eg png, tif, jpg files) helpfully shows icons that include letters that are actually the extension, but that’s not true of all file types. Would you be able to guess, for instance, that the file called “londonlocationlist” is a text file (in other words, like a word document but with no formatting)?

Whether file extensions are hidden or displayed depends upon a user setting. Personally, I’ve always thought it a bit condescending of Microsoft to hide file extensions by default (as if they think we’ll be confused and overwhelmed by all the information and might break something by changing the file extension). A lot of my computer support clients may have noticed that I tend to change the setting to “show file extensions”. It can be much easier to work out which file you want if you can see its extension.

You can change the setting as follows:

Windows XP

  • Open Windows Explorer (eg by double-clicking on “My Computer”).
  • Click on the “Tools” menu option.
  • Click on the “Folder Options” sub-option.
  • Click on the “View” tab.
  • Find the item called “Hide extensions for known file types” and uncheck the box by clicking on it.
  • Click the “OK” button.

Windows Vista

  • Open Windows Explorer (eg by double-clicking on “My Computer”).
  • Click on the “Organize” button.
  • Click on “Folder and search options”.
  • Click on the “View” tab.
  • Find the item called “Hide extensions for known file types” and uncheck the box by clicking on it.
  • Click the “OK” button.

Windows 7

  • Click on the Windows “Start” button.
  • Type “extensions” into the search box (but don’t press “Enter”).
  • Look above the search box and click on the optin that now appears called “Show or hide file extensions”.
  • Find the item called “Hide extensions for known file types” and uncheck the box by clicking on it.
  • Click the “OK” button.

The main reason that Windows hides the file extension by default is probably to stop the extension being renamed by accident. If you change the file extension (when renaming the file) then Windows won’t know how to open the file. It’s easy enough to rename it back to what it should be, but, nevertheless, care should be taken not to change the extension accidentally.

© 2011-2019 David Leonard
Computer Support in London
Privacy Policy Suffusion theme by Sayontan Sinha