I'm a DJ and have stacks of mp3s on my laptop. What I usually do is open the track in Ableton, wait for it to calculate the BPM, and then adjust the track name to XXX_Artist_Track, where XXX is the BPM of the record. I have experience with programming too, so what I'd like is be able to point my program at a directory, have it calculate the BPM of the tracks and change the track name accordingly.
Sure you can. It would require some knowledge in audio programming and analysis. However, I would advise to not reinvent the wheel and use existing tools, such as BPM Counter (free).
I'm not sure if it can write the BPM into the file name directly, but once it's saved in the id3 tag, it's much easier to access it with your own program and then rename the file.
If you have an iPhone or iPad you might want to check out the app Tempi which does just what you're asking. http://madebywindmill.com/tempi/
If you wanted to code this up yourself, look at the