by Brandon Rhodes • Home

New Year’s meme: What are the oldest files in your home directory?

Date: 1 January 2009
Tags:computing, python, web notes

Celebrate the new year with a blog post discussing the oldest files that are still sitting somewhere beneath your home directory! The procedure is simple:

  1. Run the following script in your home directory. (You might want to use less to read the output.)
  2. Ignore files whose date does not reflect your own activity.
  3. List the oldest files in a blog post and discuss!
#!/usr/bin/env python
"""Print last-modified times of files beneath '.', oldest first."""
import os, os.path, time
paths = ( os.path.join(b,f) for (b,ds,fs) in os.walk('.') for f in fs )
for mtime, path in sorted( (os.lstat(p).st_mtime, p) for p in paths ):
    print time.strftime("%Y-%m-%d", time.localtime(mtime)), path

Only include files whose last-modified time is a date on which you really touched the file. The file's time should neither result from an error (a few files beneath my own home directory have an incorrect date of 1970-01-01), nor from unpacking someone else's archive that has old files inside of it. For example, I myself have excluded the following pair of nearly 17-year-old files because their dates reflect their age inside of the Python 3.0 source archive, instead of the actual moment last month when they became part of my home directory:

1992-03-02 ./src/Python-3.0/Demo/scripts/
1992-03-02 ./src/Python-3.0/Tools/scripts/dutree.doc

But there is no requirement that the actual content of each file you list be your own. Whether you wrote the file yourself long ago, or downloaded it from some ancient and forgotten FTP site, you have a story to share!

Within the rules given above, here are the oldest files beneath my own home directory:

# My oldest five files!
# (The links return their content.)

1989-05-17 ./archive/unixpc/cee/crobots/BCRMAD.R
1989-05-17 ./archive/unixpc/cee/crobots/BCRONE.R
1990-01-18 ./archive/unixpc/ref/train.gz
1990-01-18 ./archive/unixpc/ref/xmas.gz
1990-05-18 ./archive/unixpc/save/Rhodes/treasure

You can see that these files were moved, long ago, into an archive directory for files that are no longer part of an active project. These files all date from the era when my home directory was hosted on the Unix PC which my father, a Bell Laboratories engineer, brought home in the 1980s as our personal computer.

We should start with the zipped files from January 1990, since they actually contain even older content, from December 1987 —more than twenty years ago! My father received them as Christmas greetings from fellow engineers at the Labs. You can view xmas right in your browser, since it is a simple ASCII-art holiday greeting (the name “Merrimack Valley” at the bottom refers to the particular Bell Labs location at which my father worked). Viewing train is more difficult, since it contains a VT-100 animation that will display much too quickly if you dump the file to a modern terminal. Instead, download the file and use this Python program to display it at a more traditional speed; you might want to light a candle and play some Christmas music while the animation is displaying:

#!/usr/bin/env python
"""Display the 'train' file, slowly."""
import sys, time
for c in open('train').read():
    time.sleep(1.0/9600.0) # (drat, really sleeps 0.01s)

Though Dad probably retained the files only through the Christmas season, I was fascinated by watching them scroll silently across the black screen in glowing, green, phosphoric characters that seemed to leave trails behind them like shooting stars, and so I kept the files long after many subsequent Christmases had come and gone.

The other three files are all plain-text files, and are all of my own making. The BCRMAD.R and BCRONE.R programs were experiments in the old crobots game, where you wrote small C-language programs to control robots that drove around on the screen and shot at each other. The names seem to refer to the fact that the first file simulates a “mad bull” that drives straight at targets shooting as fast as it can, while the second program always takes “one shot” at a target then flees to another location on the screen. This would have been one of my very first forays into C programming — perhaps my very first — and so the algorithms are, I must admit, not exactly pinnacles of sophistication.

The last file is named treasure, and it is, indeed, a real treasure of a file to have discovered this New Year's morning! It is my long-lost account, carefully annotated with the venerable mm macro package (as you can see from the troff include directive on the first line), of the day in early 1990 when I discovered buried treasure that my father had hidden as a child on my grandparent's property! I actually saw the “treasure” last week (an ancient coffee can with old toys inside) sitting on a shelf when I visited my grandmother on Christmas Day. I will have to pull it down from the shelf and put some pictures on Flickr, along with excerpts from this long-lost story of its discovery!

In the meantime: what are the oldest files under your home directory?