cmd - error "\.. was unexpected at this time" -
i have created .reg add delete empty folders command in context menu. when right click on folder, should delete empty child folders.
i have "delete empty folders" in context menu when select this, cmd windows open , error: .. unexpected @ time. idea why?
windows registry editor version 5.00 [hkey_classes_root\directory\shell\delete empty folders] [hkey_classes_root\directory\shell\delete empty folders\command] @="cmd /c /f \"usebackq delims=\" %%d in (`\"dir \"%1\" /ad/b/s | sort /r\"`) rd \"%%d\"" the code comes @mmj (here)
edit: josephz here solution:
windows registry editor version 5.00 [hkey_classes_root\directory\shell\delete empty folders] [hkey_classes_root\directory\shell\delete empty folders\command] @="cmd.exe /k /f \"usebackq delims=\" %%d in (`\"dir \"%v\" /ad/b/s | sort /r\"`) rd \"%%~d\""
i don't apprehend why code fails. debugging purposes: both next .regs work:
windows registry editor version 5.00 [hkey_classes_root\directory\shell\list subfolders2] [hkey_classes_root\directory\shell\list subfolders2\command] @="cmd.exe /k /f \"usebackq delims=\" %%d in (`\"dir \"%v\" /ad/b/s | sort /r\"`) @echo \"%%~d\"" changes made on code:
cmd.exeinstead ofcmd;/kswitch keep command prompt window open;%vinstead of%1work%1well;@echoinstead ofrdnot want delete directory if empty (merely debug);%%~dinstead of%%d.
another escaping approach:
windows registry editor version 5.00 [hkey_classes_root\directory\shell\list subfolders] [hkey_classes_root\directory\shell\list subfolders\command] @="cmd.exe /s /k \"for /f \"delims=\" %%d in ('dir \"%v\" /ad/b/s ^| sort /r') @echo \"%%~d\"\"" excerpted cmd /?:
if
/cor/kspecified, remainder of command line after switch processed command line, following logic used process quote (") characters:
if of following conditions met, quote character on command line preserved:
- no
/sswitch- exactly 2 quote characters
- no special characters between 2 quote characters, special 1 of:
&<>()@^|- there 1 or more whitespace characters between 2 quote characters
- the string between 2 quote characters name of executable file.
otherwise, old behavior see if first character quote character , if so, strip leading character , remove last quote character on command line, preserving text after last quote character.
edit: solution (suggested op arone time after time):
windows registry editor version 5.00 [hkey_classes_root\directory\shell\delete empty folders] [hkey_classes_root\directory\shell\delete empty folders\command] @="cmd.exe /k /f \"usebackq delims=\" %%d in (`\"dir \"%v\" /ad/b/s | sort /r\"`) rd \"%%~d\""
Comments
Post a Comment