I often need to quickly copy the name of a folder in Windows 7, and so am trying to create an equivalent to the Copy as path item that appears in Extended context menus (i.e. when doing Shift+Right Click) that will copy only the name of the selected folder to the clipboard.
I've created the Registry key at:
HKEY_CLASSES_ROOT\Directory\shell\Copy folder name\command
...where all of my similar context-menu additions for folders are, and it can be seen here:
However, I've so far been unable to get the code that needs to be executed by the key working as it should. I've come across this solution to grab the current folder of a directory, and this one to pipe the directory name to the clipboard, and put them together to get the following:
for %* in (.) do set FolderName=%~nx* && echo %FolderName%| clip
This code works exactly as expected in the command line.
Prepending cmd /c to it, which is necessary to run a CMD instance from the Registry, gives the following:
cmd /c for %* in (.) do set FolderName=%~nx* && echo %FolderName%| clip
However, placing this in the value data of the Default string value in the \Copy folder name\command key, and then right-clicking a folder and clicking on Copy folder name fails to work.
Wrapping it in quotes also does nothing:
cmd /c "for %* in (.) do set FolderName=%~nx* && echo %FolderName%| clip"
What am I missing here?

