I don't think you need to go to any bother doing what your doing.
Try this post I previously posted in relation to the something similar. It may be of interest to you. Them tracks you're referring to are called 'orphan tracks' whereby they're in your music library location but not actually part of the iTunes library itself. The tool in that post can search the folder library location against that of the 'iTunes Music Library.xml' file and get rid of all the dups, orphan tracks etc.