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.

2001-05-31 ./Sites/trajiklyhip.com/_OLD/stats/ctry_usage_200105.gif
2001-05-31 ./Sites/trajiklyhip.com/_OLD/stats/daily_usage_200105.gif
2001-05-31 ./Sites/trajiklyhip.com/_OLD/stats/hourly_usage_200105.gif
2001-05-31 ./Sites/trajiklyhip.com/_OLD/stats/usage_200105.html

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.

2001-10-12 ./Documents/downloads/Fusebox/FB4 Layout Examples/Nested Layout - Nested Circuits/family/Parent/child/grandchild/dspfuseaction.cfm

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.

2001-11-15 ./Sites/trajiklyhip.com/tutorials/wddx_ColdFusionFlash/**path_removed**/Employees.mdb

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).

pico findoldestfiles.sh

Paste the following code into the resulting file edit window.

#!/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

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:

chmod +x findoldestfiles.sh

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!


Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on January 5, 2009 at 8:00 AM. It was filed in the following categories: ColdFusion, Mac Programming, Mac, Flash. It has been viewed 8125 times and has 0 comments.

0 Responses to The Oldest Files in My Home Directory