How to delete N files of X type from Y subfolders from a Windows batch file?

I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects.

  • I need to delete files of X type,
  • I have the parent folder C:\MyProject,
  • There are Y subfolders C:\MyProject\?,
  • There are N files to delete.

Is there a quick del (of type) function I am simply missing?

Answers


Actually you can use the standard del command:

c:
cd MyProject
del /S *.type

Where type is the extension you want to delete and the /S parameter will check in all subfolders of MyProject.


Need Your Help

How to query Code First entities based on rowversion/timestamp value?

c# sql-server entity-framework ef-code-first rowversion

I've run into a case where something that worked fairly well with LINQ to SQL seems to be very obtuse (or maybe impossible) with the Entity Framework. Specifically, I've got an entity that includes a

Check whether function is declared with C preprocessor?

c macros c-preprocessor

Is it possible to tell the C preprocessor to check whether a function (not a macro) is declared? I tried the following, but it doesn't appear to work: