Home | Programming Resources |     Share This Page

Ever wonder why your files sometimes just disappear? Want to have a logical way to store your computer's data? This article reveals some facts and concepts about file storage that most people just don't know, information that could prevent you from losing irreplaceable data.

I get lots of e-mail from people who are using my program Arachnophilia to create Web pages. The task of creating a Web site requires one to store various files on a personal computer, then, after the page is completed, on a Web server computer. Both these actions require you to know something about file storage.

Nearly everyone gets into difficulty sometime in this process, either on the personal computer or the Web server or both. I designed Arachnophilia to move all the files and resources into one directory by default, hoping to minimize these difficulties, but this approach doesn't solve all the problems. This article summarizes the problems I hear reported from loyal Arachnophilia fan club members, plus the distilled everyday wisdom from my own experiences.

Here are the two principles you need to know to securely store and find your files:

Principle #1: Put personal files and program files in separate directories.

There are two main classes of file on a computer --

One class, program files, are files that you can recover from a CD or set of disks or download from the Web. This class of files isn't very important to back up, because if Windows crashes severely or you upgrade to a new operating system, you will have to re-install your programs completely anyway. Also, you don't own program files, you haven't invested hours of effort in them. There are plenty of ways to get another copy of a program.

The other class of files are personal data files. These files have been created by you. They may represent weeks of work, they are unique, if you lose them they are gone forever. And, if you are an average computer user, you have one backup or no backups of these files.

Because these classes of files are treated differently, one being immediately replaceable, the other representing much personal effort, they should not be mixed together.

Step 1: Create two main directories, one for programs, one for data:

Step 2: Create subdirectories under these main directories for each program and task:

Step 3: Find all your files and move them into these two categories.

This means always putting new data files into a subdirectory of the data directory, and it also means installing new programs under the program directory. With the single exception of the Windows system directory, nearly all files and folders can be placed into one of these two main categories.

This principle may require you to adopt new habits. For example, when you press "Save," where is the file being saved? You should know — you should make a conscious decision to place files of a particular kind in a particular place.

Step 4: When you acquire a new program, don't allow the install program to put it in your system's root directory:


This principle has several important benefits. One, when you back up your files, all the files worth backing up are under the data directory — this saves time locating files for backing up. Two, if you create subdirectories instead of putting all your files in a gigantic pile, your computer will find files more easily and run faster. Three, you will always know what folder (directory) a particular kind of file is in.

Microsoft has begun creating a folder called "Program Files," and newer programs automatically install themselves under this directory, so this idea is catching on. Microsoft has also begun using a folder called "My Documents" that is the equivalent of the "data" directory in this example. But there is one problem with this arrangement — the folder name has spaces in it, which makes it difficult for Web-aware software to work with it. Which leads to --

Step 5: If you need to put your files on the Web, avoid spaces in the names of the files or directories, and avoid using uppercase characters.

I could just as well have said, "avoid lowercase characters," because the point is to be consistent — use all uppercase or use all lowercase, but don't mix uppercase and lowercase. Lowercase is generally preferred.

The reason for this is Windows doesn't care about the case of file names, and also doesn't care if there are spaces in directory and file names, but most Web server computers care about both. The majority of Web server computers are running UNIX, not Windows, and under UNIX, a file name like "this is my page.html" is simply not acceptable. To make this file acceptable to UNIX, you should change it to read "this_is_my_page.html."

If you have a file named BIGtree.GIF, and you create a tag that refers to it -- <IMG SRC="bigtree.gif"> — the tag will work perfectly under Windows, but UNIX cares about the case of file names, so when you upload this page onto the Web, you won't see the graphic any more.

Step 6: Arrange your directories in a logical way.

This principle is especially important in the design of a Web site. If you divide your pages into categories and place the resources for each subject in a separate folder, make each such folder a subdirectory of the main Web site directory. Example:

It is especially important not to permit needed resources to be placed outside the Web site directory tree — once again, this is something that will work at home but will not work when you have uploaded your page onto the Web.

If you have no better reason, do this because Arachnophilia has an intelligent FTP client service that searches your directory tree for changed files, and moves those files into a corresponding directory tree on your Web site, creating the tree if necessary as it proceeds. If all your resources are located together in a single directory structure such as that shown above, the FTP client will be able to move your files between your computer and your Web site quickly and easily.

Principle #2: Back up your files.

Here are two stories about file backup and loss.

1. The Raisin

I wrote programs for Apple Computer in their early days. One day I showed up with a new program I wanted them to see. I brought two copies, just in case something bad happened. I gave Steve Jobs one of the two copies for safekeeping and started showing off the other one. Pretty quickly, someone got the bright idea that I should use the new version of DOS to make a copy of the disk. But, because of a bug, DOS ate my program for lunch instead of copying it. I quickly called Steve, who by then had been driving around for hours with the disk on his car's dashboard. It being California, the disk had gotten seriously sunbaked and had turned into a sort of plastic raisin (in the days when "floppy disks" were literally floppy).

I got Steve to come back with the disk, cut open the "raisin" with a scalpel, and inserted the inner media into a new disk envelope. The drive didn't spin with quite its normal smooth silence, but it was able to read the disk. Thus was some forgotten program saved.

2. Electrifying

A few years ago I lived in a wood-heated cabin on a hilltop in Oregon, where I was writing a word processing program (okay, it was Apple Writer). A lot of disks had been filled with code in a few days, a lot of sleep and meals missed. My sole aim was to create this wonderful program, and with my Apple II humming away on power from a portable gas generator, I felt completely removed from the mortal world, in a kind of rapture.

Outside, a storm blew in as I worked. Then bam! — lightning struck a tree just outside the house. Sparks flew all over my desk, zapping my pile of backup disks and resetting the computer to its dumbest state. As I got up off the floor, I realized I might have lost all copies of my great program. Suddenly and thoroughly mortal again, I began issuing a barrage of commands to the computer to try to save its memory of my program. I tried about a half dozen truly arcane things without effect. Then I found a command that worked. The screen filled with the program, just as I had left it. I stepped back. The computer had crashed blindly into nature and survived. Its little red lights were blinking, its disk drive spinning. How can I say it — I was in love (click here for the complete article from which this was taken).

I have been rather lucky in my dealings with computers, mostly because I don't trust them, but I regularly hear from people who are not so lucky. The old saying "My dog ate my homework" is quickly being replaced with "My computer ate my homework" (Once someone raised a monitor lizard as a science project — then he showed up and said, "My homework ate my dog").

The first principle of file storage: If you think you have two copies of a file, you probably only have one. If you think you have one, you probably have none.

People who don't spend much time with computers imagine a clean, glass-enclosed room with a lot of people wearing lab coats and surgical masks scurrying about making sure vast reams of data are secure. In fact, studies show computer storage media are generally the least reliable storage method you can choose.

I have four computers at the moment, tied together in a network. When I am working on an important project, a situation in which new files are being created and there are not many backup copies, I regularly run a backup program I designed. The backup program compares the directory on my main work machine with the other three, and copies any changed files so all four machines have identical file sets ( Arachnophilia now has a similar function for updating Web sites). I also make tape backups and keep them in various places — you know, the house might burn down, an earthquake might shake a hard drive loose, a meteor might poke a hole in my roof (if you think these fantasies are far-fetched, please go back up the page and read the lightning story again).

Obviously, simply having copies of a file isn't enough — you have to be sure the file you are backing up is actually what you think it is, otherwise you might be replacing a valid file with one that has been damaged or is a zero-length file with the same name as your magnum opus. Not only should you back up regularly, you should also review the contents of your files regularly to be sure they are what they appear to be.

Diskettes are no longer practical for hard drive backup . As drives get larger, the probability that you will successfully write and then read all those diskettes becomes smaller and smaller. Get a tape drive or a removable-media hard drive as a backup device.

Want to learn about HTML? Visit my HTML tutorial

These Pages Created and Maintained using    Arachnophilia.

Main Page
Home | Programming Resources |     Share This Page