Reputation: 3
I want to delete all files from my "music" folder that aren't .mp3, .mp4 or .m4a.
This is the folder structure:
H:/Music/Artist/Album/Files
There are pictures like Folder.jpg, playlist files, .txts and etc in those folders.
I'm running Windows 8.
Upvotes: 0
Views: 1957
Reputation: 37569
set up an array with do-not-delete-extensions and compare all files with it:
@ECHO OFF &SETLOCAL
SET "startfolder=H:/Music/Artist/Album/Files"
FOR %%a IN (
.mp2
.mp3
.mp4
.m4a
.wav
.flac
.ac3
.dts
) DO (
SET "$%%a=1"
)
FOR /r "%startfolder%" %%a IN (*) DO IF NOT DEFINED $%%~xa ECHO DEL "%%~fa"
Please note: files without extension will be deleted.
Upvotes: 2
Reputation: 12985
You could try:
Upvotes: 0
Reputation: 56180
If this is a "one time task", use windows explorer (sort for "type"). This will be much faster (and safer) than writing and testing a batch for it.
Upvotes: -1