You can attempt to prevent it from happening by perhaps laminating your N97 so it would never get the slightest bit of dirt.
Alternatively, you can check Ricky Cadden’s post on Symbian-Guru of how to fix the lens slider so you hopefully won’t get scratches.
If you’ve already got scratches over your N97’s lenses, Micky from NokiaUsers may have a solution for you. Replacing the N97 lens cover outright.
It’s the same self-harming lens cover so you may want to still check Ricky’s post out.