Windows 7 Context Menu for Folders – *IF* folder contains certain filetypes

context menuwindows 7

I would like to add an entry to the context menu for folders, but only have it show in the context menu IF the folder in question contains files of a certain type (in this case, only if the folder contains .avi files). Is this possible?

I'm sure I've seen at least one program which only had its context menu entry shown in certain folders – though I can't for the life of me remember what it was.

Best Answer

I know this is an old thread, but since there wasn't much on google for this topic.... I wanted to add a little more... Mostly this is just tacking onto what harrymc mentioned, but maybe this will help those less comfortable with registry editing...

First, there are actually tons of API methods available from the System object mentioned above. For example, instead of ItemName you could also check System.FileName (which worked better for me) or System.ItemFolderPathDisplay ...

Second, the search syntax is somewhat involved but actually gives you a lot of options. You can use the standard DOS wildcards in the AppliesTo test (e.g. "?" for exactly 1 character, "*" for 0 or more characters). You can use a variety of operators against the name... such as equal, not equal, contains, starts with, ends with, etc. You can string together multiple conditions with "AND" or "OR" keywords (or use "NOT").. It seems like you can even do some SQL-ish sort of search syntax, but I haven't been able to get these to work natively via the registry (I could just have the syntax wrong... not sure).

3) While I haven't found the solution to the question asked, the following registry scripts shows how you can show or hide context menu items based on folder name and location. I just have it poppin g up a command prompt but you could easily change to whatever else.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\# Ends With '_mydata']
"AppliesTo"="System.FileName:\"*_mydata\""

[HKEY_CLASSES_ROOT\Folder\shell\# Ends With '_mydata'\command]
@="C:\\Windows\\System32\\cmd.exe /k cd /d \"%1\""

[HKEY_CLASSES_ROOT\Folder\shell\# Starts with 'C:-slash-[Videos]']
"AppliesTo"="System.ItemFolderPathDisplay:~< \"C:\\[VIDEOS]\""

[HKEY_CLASSES_ROOT\Folder\shell\# Starts with 'C:-slash-[Videos]'\command]
@="C:\\Windows\\System32\\cmd.exe /k cd /d \"%1\""

[HKEY_CLASSES_ROOT\Folder\shell\# Starts with 'C:-slash-[Videos]' AND ends with '_mydata']
"AppliesTo"="System.FileName:\"*_mydata\" AND System.ItemFolderPathDisplay:~<\"C:\\\""

[HKEY_CLASSES_ROOT\Folder\shell\# Starts with 'C:-slash-[Videos]' AND ends with '_mydata'\command]
@="C:\\Windows\\System32\\cmd.exe /k cd /d \"%1\""
Related Question