@Jerome, @John Doe: Of course, for commands that apply only to a *simple* and *reduced* set (for example, JPEG images), it's better to just show it when needed. I was talking about *complex* or *confusing* rules, like showing the command for all files but not for Word documents, or files with a extension longer than three characters. These complex rules, in practice, aren't used very often. So if they will apply most of the time, they will add to the clutter anyway. You don't lose much showing the command in the few cases where they don't apply, and you can gain a lot in usability and cut in product support costs.
The idea isn't mine, and isn't new. That's why many applications disable menu commands when not applicable instead of hiding them. It traces back to the first volume of Inside Macintosh, where Apple explains the best practices of the then revolutionary Macintosh user interface, and the reasons behind them. It was published in 1984, but is generic enough that it can be applied today - you will be surprised how much of that is still in use after 30 years!