Recursively delete files by extension

Recently, I got the task to remove all MP3- files from some shared folders (SMB shares). To do so, I wrote a tiny batch- script wich processes the DIR command’s output and examines it to match the MP3 extension.

Usage:
The script processes all folders and subfolders in its working directory (e.g. if you run it in c:\scripts it processes all folders and subfolders from there on – c:\scripts\*)


@ECHO OFF
FOR /F "tokens=*" %%G IN ('DIR /B /S *.mp3') DO DEL /F "%%G"

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.