Monday, July 7, 2008

My first Ruby script: finding duplicate photo files

I've started on the large task of organizing my digital photo files. My disorganization stems from a couple of things. First, when I began using a digital camera, I used iPhoto. I don't really use it now. But I've noticed that iPhoto makes some duplicate files. Second, I think I have duplicate files from backups and from migrating from old machines to new ones. Compounded with the fact that most of the files begin with DSCN or DCP, it is a mess. So, to help me get started, I thought I would write a script that would create a report of any duplicate files and their locations. Also, since I'm about one third of the way through the Everyday Scripting with Ruby by Brian Marick, I know just enough to be dangerous. After a couple of evenings of blundering my way through this, I finally have my first Ruby script.



To call this script, you can pass in a list of directories, or it will default to the current directory.

Sunday, July 6, 2008

TextMate

I have started using a nice Mac OS X text editor called TextMate, and so far am liking it very well. I'm working with the 30 day trial before deciding whether or not I want to buy it. It comes with support for many languages. I like that you can execute shell commands from within TextMate itself, saving time from flipping back and forth between applications. I also like the collapsible code blocks. This was a feature I loved about QAPartner/SilkTest, and it is nice to see that here.

One thing that did take me a while to figure out was how to get TextMate to recognize environment variables. It turned out that I had no .bash_profile configured in my home directory, and TextMate sources this before it runs a script. So, in my case, I needed for TextMate to find Subversion. I created the following .bash_profile in my home directory:



[ -f /etc/profile ] && . /etc/profile
[ -f ~/.bashrc ] && . ~/.bashrc

export PATH="/opt/subversion/bin:$HOME/bin:/opt/local/bin:$PATH"


After restarting TextMate, I was able to call svn from within my Ruby scripts inside of TextMate.