First, scratching is a perfectly normal behavior in a cat. It's how they shed old claws. Punishing them for it is like punishing a person for burping.
Provide plenty legal scratching targets, and use a variety of surfaces. Sisal, carpet, cardboard, etc. Cats will decide what they like and you'll know to provide it. Encourage them to scratch on the legal surfaces, and discourage on the illegal surfaces. Positive reinforcement is your friend.
In addition, keeping the cat's claws trimmed will help. Get a pair of trimmers from the pet store, I've never found human style to work. Be careful not to cut the quick, as then you'll have a mess on your hands in addition to hurting the cat. You may have to do one paw at a time and then try again later, depends on the cat.
And yeah, loop carpet is awful with cats. Even if they're not scratching on it, their claws can catch on it and pull without meaning to.