Remove all the clothes from your closet and from any storage bins. This will give you better access to clean the closet.
Search for the source of the odor to determine if it is caused by mildew or mold. If you see mold spores or smell the characteristic odor of mildew, place a dehumidifier in the closet to make the environment less hospitable for mold or mildew growth. Remove all visible mold spores from the walls, ceiling and floor of the closet, and wash any clothes that smell bad.
Sprinkle baking soda on the carpeted floor of the closet. After letting the soda sit for several hours or overnight to absorb any embedded odors, vacuum the carpet thoroughly.
Rehang your clothes on hangers made from cedar wood. The wood has a pleasant scent, and also repels insects that might eat away at your apparel.
Store each pair of shoes in a separate box with a sprig of dried lavender to fight foot odor.
Spray fabric refresher spray on the clothes and on the carpet.
Move your laundry hamper out of the closet, if that is where you normally store it. The bacteria on sweaty clothes in the hamper can make your entire closet smell rank.