Deleting folders using wildcards

When doing manual/batch cleanups, I ran into an issue. The rmdir / rd command alone doesn’t support wildcard characters (that is, * and ?). However, I found a workaround that uses a for loop

For example:

for /d %G in ("C:\MSI*.TMP") do rd /s /q "%~G"

This will loop through all MSI*.TMP folders and delete them. However, I’d advise using echo for the first run, so that you can see what is about to be deleted. So above becomes:

for /d %G in ("C:\MSI*.TMP") do echo "%~G"

As usual be careful when removing files/folders.