This script will convert the selected tracks using an encoder chosen on-the-fly (the encoder's current Preferences-set options will be in effect) and replace the originals throughout the playlists of your entire library with the newly converted versions. Additionally, you can opt to Trash/delete or keep the original files and tracks.
(Possible deal-breaker: newly converted tracks will have a Date Added of "now". There is no getting around this since Date Added is a read-only property assigned by iTunes when a new track is added to its library.)
For OS X 10.6 or better.
Replace occurences of a selection of tracks with their newly converted versions throughout the library. Trash or keep the originals.