How can deleted computer files be retrieved at a later date?

Join Our Community of Science Lovers!

Clay Shields, a professor of computer science at Georgetown University, explains.

The details of how this occurs depend on the operating system (OS) the computer is running, but the basics tend to be similar. A computer disk stores information in a series of chunks known as sectors, each typically 512 bytes long. Each sector has a number that serves as its address on the disk. A file on the disk is split across a number of sectors. These sectors may be located together but might be scattered across the disk if there is not enough contiguous space in one spot. The OS has an index mechanism to keep track of which sectors belong to which file--the particular mechanism varies by OS, but they all do it. Additionally, because sectors are addressed by numbers and people care more about names than numbers, the OS also stores a directory that maps the file name to the index entry about which sectors contain the file's information.

As an analogy, consider the disk to be a filing cabinet that contains a long series of consecutively numbered folders, each of which can contain only a few pages of information. A particular document might be split among many folders if it is too big to fit in just one. The first drawer of the cabinet holds a big directory that has a list of all the documents in the cabinet. The folder number associated with a particular document holds an index to all the other folders that contain the parts of the document.


On supporting science journalism

If you're enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.


When a file is deleted, the information stored in the individual sectors is not erased, because the erasure process consists of overwriting the sector and is relatively slow. It is significantly faster to overwrite the sector by rewriting it with new data only when it is needed for some other file. So when a user "deletes" a file, the directory entry for the file is either removed or marked as deleted by changing the first letter of the file name to a special character (which again differs depending on the OS). The index entry and the sectors are then made available as space for new files but are left untouched until needed.

A deleted file can thus be recovered if the index information and sectors have not yet been reused. The chances of this are better if little computer activity has occurred since the file was deleted, so it is best to attempt to recover the file as soon as possible. In operating systems that simply change the directory entries, recovery programs have a pretty easy time. They scan the directory for filenames that have the special character that signifies "deletion" and present a menu of files to recover. When the accidentally deleted file is chosen, the directory entry is corrected and the file reappears. In other operating systems, the recovery programs have a more complicated task. The name that was in the directory may be lost, making it harder for the user to find the specific file she wants, and the program generally must look through all the index information and attempt to recover files from their individual sectors. Also, because sectors may have been reused from the middle of the file, only parts of the file may be recoverable.

Answer originally published December 15, 2003.

It’s Time to Stand Up for Science

If you enjoyed this article, I’d like to ask for your support. Scientific American has served as an advocate for science and industry for 180 years, and right now may be the most critical moment in that two-century history.

I’ve been a Scientific American subscriber since I was 12 years old, and it helped shape the way I look at the world. SciAm always educates and delights me, and inspires a sense of awe for our vast, beautiful universe. I hope it does that for you, too.

If you subscribe to Scientific American, you help ensure that our coverage is centered on meaningful research and discovery; that we have the resources to report on the decisions that threaten labs across the U.S.; and that we support both budding and working scientists at a time when the value of science itself too often goes unrecognized.

In return, you get essential news, captivating podcasts, brilliant infographics, can't-miss newsletters, must-watch videos, challenging games, and the science world's best writing and reporting. You can even gift someone a subscription.

There has never been a more important time for us to stand up and show why science matters. I hope you’ll support us in that mission.

Thank you,

David M. Ewalt, Editor in Chief, Scientific American

Subscribe