Using Wild card for removing directory in dos

batch-file, command-prompt, directory, dos, wildcard

Solution

double the % signs to use it in a batch file.

@echo off
for /d %%a in ("C:\Inbound\Extract\NA_monthlyGP_*") do rd /s /q "%%~a"

Problem

I am working on a application that needs to remove folders from inside a folder. BUT the Folder name will have the same general name minus the end of it. `NA_monthlyGP_20130131`, The numbers will change. It is housed in this following path `C:\Inbound\Extract` I want to remove it but keep the parent directory, `Extract`.

Original source