It's certainly possible to write a context-menu handler whose entry that will only show up in the menu if certain files exist in the directory. A context-menu handler is a program that is free to decide whether to show up or not, although this might slow down the appearance of the context-menu for folders.
The only general mechanism in Windows for this to happen is Windows Search Advanced Query Syntax.
One of the new features in Windows 7 is the addition of the "AppliesTo"
value for static context menu items. This lets a static item be shown or
hidden based on the result of an AQS query.
In this example, the DefaultAppliesTo value makes this verb the default for any file with the word "exampleText1" in its file name. The AppliesTo value enables the verb for any file with "exampleText1" in the name. The HasLUAShield value displays the shield for files with "exampleText2" in the name.
HKEY_CLASSES_ROOT
txtile
shell
test.verb
DefaultAppliesTo = System.ItemName:"exampleText1"
HasLUAShield = System.ItemName:"exampleText2"
AppliesTo = System.ItemName:"exampleText1"
As AQs is not well-documented, I haven't been able to find the syntax for querying a folder's content.