Cedar-lined storage chests and closets have long been used for long-term storage of out-of-season clothing, in the belief that the cedar will deter moths from destroying the clothing. The damage moths cause to natural fibers is caused not by the moth itself, but by the larvae that hatch out of the eggs the moth lays. Cedar has a strong smell, which might hide the odor of wool, but some forms may also kill the larvae over time.
The heavy scent of the cedar is thought to mask the smell of wool, effectively hiding it from the moth seeking a home for her eggs. That is, it doesn't repel moths so much as it camouflages the moth's natural target. If the smell-disguise in fact does deter moths, then any masking smell would work as well, and people have packed old garments away with sprigs of lavender, tansy and rosemary tucked in them for literally centuries.
If the scent-deterrent works — and there's only anecdotal evidence that it does — then it only works on the egg-laying moth. Packing away garments already hosting moth-eggs will yield a cupboard full of rotting wool. Since the larvae are repelled by strong light, shaking and hanging clothing in the sun for a few hours before folding for storage should ensure that what is being stored is larvae-free.
Mothballs have been used to destroy the emerging larvae, but this method is less popular than it once was. The smell that mothballs leaves on clothing is reason enough to avoid their use, but a further deterrent should be toxins they contain. These chemicals slowly vaporize, creating a toxic vapor that kills moth larvae, but which is also dangerous to people and pets.
A report from the University of California at Davis suggests that one type of cedar, Eastern Red Cedar (which is actually a juniper), does kill moth larvae over a period of time. The wood contains an aromatic oil that, in sufficient concentration, like in an airtight cabinet, will kill small moth larvae. If there is too much air circulation, as in a closet, concentration of the vapors will remain insufficient to kill larvae, although the scent might deter adult moths.
Whether other junipers — or juniper essential oil, which is made from another form of juniper, and from the berries, not the wood — will protect clothing from moths, has not been determined. Even Eastern Red Cedar is only effective against moth larvae for a few years, after which the aromatic oil has evaporated. The presence of a pleasant cedar-scent in grandma's old hopechest is not proof that the box will protect woolens from munching moths.