# Solved: DOS - Remove Long Filename Directory



## lagunasrfr (Feb 13, 2005)

I'm trying to remove long filenames with wildcards. In particular, I want to remove all of this format:
{nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}

I thought the special character "{" was causing the problem, but if I make a directory such as:
12345678-1234-1234-1234-123456789012
I can't remove it either using wildcards.

I've tried:
rd {????????-????-????-????-????????????}
rd {*
rd {*.

If I use rd {nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn} where n=actual character in filename, it will remove the file from the directory.


----------



## TheOutcaste (Aug 8, 2007)

*RD* does not support the use of wildcards. You can use this:

```
For /F "Tokens=* Delims=" %I In ('Dir /AD /B {????????-????-????-????-????????????}') Do RD %I
```
That will not remove directories that are not empty, or have the hidden, system, or Read Only attributes set
Use *RD /S %I *or *RD /S /Q %I* for that.

If using in a batch file, use two *%* symbols for the Loop variable (*%%I*)


----------



## lagunasrfr (Feb 13, 2005)

Thanks, Outcaste. It worked. Used %% for batch.


----------

