I was reading through the latest blog posts aggregated by ColdFusion Bloggers and noticed someone writing about the oldest file they had in their home directory. I switch laptops every three years, but thought it'd be an interesting exercise even if I don't typically respond to memes.
I thought it would be pretty easy to determine my oldest file using OS X's Spotlight. After a minute or two I realized Spotlight wasn't going to be much help so I dipped into my ninja command-line skills and attempted to use *nix's find, and ls commands. I was able to make some headway but wasn't too sure of my results so I followed links from Jehiah's post to Craig Rhodes' blog. Craig provides a Python script that seemed to do the trick (code and instructions on how to do this yourself are below). The absolute oldest file on my Macbook Pro is a font called Optim which was created on June 25, 1987. Yikes! Scrolling through the list of files (ordered by oldest first) there were tons of fonts which have probably been forgotten for ages.
The oldest files in my home directory that are actually mine are Webalizer stats graphics I saved for this site seven years ago.
That's all well and good but I wanted to know the oldest file that has a little more meaning than seven year old Web site stats. So I scrolled down and down and down until I got to a Fusebox 4 layout example download from 2001.
Scrolling further, I reached an old Microsoft Access database file used in a ColdFusion and Flash tutorial I wrote on consuming WDDX packets in order to create a dynamic Flash movie. Using WDDX was a standard way of getting dynamic data into Flash pre Flash Remoting. The tutorial was published in October of 2001 and has received thousands and thousands of hits since.
If you want take part in this meme (c'mon you know you want to) and you're on Mac OS X, you can perform the following steps:
Open Terminal (Applications -> Utilities). You'll be located in your home directory and the first step is to create a file for the Python script (you can delete it later if you want).
Paste the following code into the resulting file edit window.
"""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
Next, press CTRL-x to exit the file edit window. You'll be prompted to save your changes. Press y to save. Then, press enter to confirm the name of the file. In order to execute the Python script you need to made the file executable. Type the following:
Now, execute the script. Once you type this command and press enter, a bunch of filenames are going to start scrolling across your screen very quickly. You won't need to see them all so press CTRL-c to abort the process. Your Terminal screen will be left with all the oldest files listed first. Scroll to the top of Terminal and check out your old files. Enjoy the nostalgia!