|Ivo's solution uses a simple FOR whereas mine uses FOR /F. I normally would also use a simple FOR. I used FOR /F because I have heard reports that strange things can happen when you are iterating over a number of files, some of which you are deleting at the same time. I have heard anecdotal evidence that using the FOR /F technique appears to work as intended.|
By the way, Ivo is right to enclose the variable in quotes. I had forgotten that in my code, it should be "%%a".