VBAbyMBA
VBAbyMBA

Reputation: 826

Remove multiple copies of folder that starts with same name using batch-file

My DESKTOP contain copies of 'CEEMEA EMEA' folder i.e.

EMEA CEEMEA

EMEA CEEMEA - Copy

EMEA CEEMEA - Copy (2)

EMEA CEEMEA - Copy (3)

and so on

I want to delete all folders that starts with EMEA CEEMEA as file name using CMD or batch-file.

rd /s /q "%CD%\NEW FOLDER*"

but above command not doing anything. how does it work?

Upvotes: 0

Views: 917

Answers (1)

Compo
Compo

Reputation: 38579

You can do this using a For loop with its /D option:

For /D %A In ("%UserProfile%\Desktop\EMEA CEEMEA*")Do @RD/S/Q "%A"

As you've updated your question to include batch-file, you'd change the command to this from one:

For /D %%A In ("%UserProfile%\Desktop\EMEA CEEMEA*")Do @RD/S/Q "%%A"

Upvotes: 1

Related Questions