How to delete files in multiple unknown folders from a single bat file?

11,797

Solution 1

Try to do

del /s *.exe

/S stands for delete from all Subfolders (DELTREE)

Solution 2

Using FOR to iterate over directories:

for /d %i in (*.*) do del %i\*.exe
Share:
11,797
PEIN
Author by

PEIN

Javascript and python web application developer.

Updated on June 04, 2022

Comments

  • PEIN
    PEIN almost 2 years

    Suppose I don't know names of all the folders in a directory. I want to delete all the .exe file in those folders from a single bat file. What will be the command? Is it possible?

    cd ?
    del *.exe