Page 1 of 1

Delete contents folder context with check

Posted: 10 Apr 2016 07:44
by Olyrd
I'm trying to add a conext menu that will detele the selected folder's contents but I want to check if the current path is set to the selected folder first.

I've written the following but It doesn't work. It does change to the folder but doesn't delete anything.

Code: Select all

REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "cmd /c \"pushd %1 ^& if \"%cd%\"==%1 (del /s /f /q *.*)\"" /f


If I execute like this, the %cd% is replaced with cmd path, which I do not want.

I tried running it like this and still does not work:

Code: Select all

REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "cmd /c \"setlocal enabledelayedexpansion ^& pushd %1 ^& if \"!cd!\"==%1 (del /s /f /q *.*)\"" /f


Any insight? Thank you

Re: Delete contents folder context with check

Posted: 10 Apr 2016 09:21
by aGerman
Percent signs that you want to have parsed/passed literally have to be doubled.

Code: Select all

REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "%comspec% /c \"del /s /f /q \"%%1\*.*\"\"" /f