Code:
reaper.Undo_BeginBlock()
for i=reaper.CountTracks(0)-1, 0, -1 do
track = reaper.GetTrack(0,i)
if not reaper.GetTrackMediaItem( track, 0 ) then reaper.DeleteTrack( track ) end
end
reaper.Undo_EndBlock("Delete Unused Tracks", -1)
Just put that in a reascript and it will blindly delete all empty tracks... It creates an undo point so you should be able to undo if you are unhappy with the result.... Good luck..
WAIT.. I'm wrong.. this will delete any track that is empty.. which accomplishes the same thing you've already figured out.... You have empty tracks that are receive tracks that you want to prevent from getting deleted? Heda's empty item idea is good... There's probably a way to tell which tracks have receives and which don't via scripting, but that's out of my depth! Good luck...