Whole nuts in their shells are a long-storage item, with many kinds of nuts having a shelf life of several months. However, they do vary widely and, unless stored in the refrigerator or freezer, it is possible that some nuts will suffer a serious loss of flavor or texture. As long as their fats have not gone rancid, it's easy enough to restore them to usable condition by baking the nuts lightly.
Shell as many nuts as you will need at one time. Pick over the shelled nuts carefully, discarding any that are shriveled, visibly moldy or have off smells.
Preheat your oven to 350 degrees Fahrenheit. Spread the nuts in a single layer on a parchment-lined baking sheet.
Bake the nuts for 10 minutes, shaking and turning the pan halfway through the baking time to ensure that they toast evenly.
Remove the nuts from the oven and let them cool. Taste one to ensure that there is no unpleasant flavor, and proceed with your recipe.
Soak the shelled nuts overnight in milk diluted by an equal amount of water, if they have absorbed undesirable flavors from other foods. Rinse the nuts, dry them on a paper towel and refresh them in the oven as directed in the previous steps.
The refreshed nuts should be used immediately for best results, but if necessary can be refrigerated in airtight packaging for a week or two without significant loss of quality.
Rancid nuts cannot be salvaged and should be discarded.