I'm on Windows 7 I have directory called e.g. dir1. It has a few subdirectories e.g. subd1, subd2 and etc. Each of this subd could have a file with extention .tmp e.g. "abc_test write.tmp" My goal: get into directory dir1 and then delete all files with .tmp in subfolders. I do:

set dir=\my_path\dir1
pushd %dir%

And here's the problem: next step I do:

del /s "*\*.tmp" 

but got the error: The filename, directory name, or volume label syntax is incorrect. My question: how could I delete files with extention .tmp is subfolders using wildcard? Thanks


The DEL command in your example should be in this syntax:

  • DEL /Q /F /S "*.tmp"

Essentially you don't need to try to wildcard any folder paths and the /S switch is used to delete specified files from all subdirectories from the directory you are in when you run the command and all the way down recursively from all beneath subfolders.

Further Resources

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.