Deleting folders using wildcards
rd command alone doesn't support wildcard characters (that is,
?). You can workaround this limitation by wrapping it in a
for /d %G in ("X:\A*") do rd /s /q "%~G"
Note As you're deleting files and folders, you might want to replace the
rd command with
echo first. This way you can ensure anything that shouldn't be deleted actually would.
In order to delete multiple folders matching different patterns the syntax is not too different. As @dbenham correctly pointed out, a one-line command is enough. You can also specify different paths:
for /d %G in ("X:\A*","Y:\Whatever\B*","Z:\C?D") do rd /s /q "%~G"
Bonus - Checking folder existence
In case you want to check whether specific folders exist, you can use the following command:
dir /b /a:d "X:\A*" >nul 2>&1 && echo Folders exist. || echo No folders found.