We had an issue not long ago were Tivoli Storage Manager was losing track of tapes. The issue ended up being how TSM manages database snapshots which are sent offsite using DRM (Bug in TSM which has been around for a while according to a colleague of mine).
I needed to find out quickly which tapes TSM had no knowledge of, and had essentially become scratch. I wrote the following script to do just that for me. You’ll need to tailor it to your environment, as our tapes are bar-coded COL000L4 through to COL120L4.