Excluding file search and deletion via cmd / bat

In x folders there are x files that have the form куча_цифр_куча_цифр.wav in the name, next to all these folders there are exactly the same files, but the name %%~a.converting.wav. How can I use the mask to find and delete everything that does not have *.converting.* in the name through cmd?

For example, something like this: (one simple line)

for /f %%a in ('dir /b /s /a-d "c:\records\*"') do if not "%%a"=="*.converting.wav" del /q "%%~a"

I just don't know what other simple ways there are, I can't get cmd to search by mask to fulfill the condition do if not

Author: sergey, 2020-01-22

1 answers

From a command line to a single line, a set of delete commands is easily called. For example, delete all nested files in the c directory:\folder that does not have the phrase in the name. converting.

for /f "tokens=1* delims=/" %i in ('dir /a-D С:\folder\* /S /b^|find/i".converting." /v') do @echo del "%i" /q
 1
Author: Daemon-5, 2020-01-23 04:16:05