For example, I can delete all .exe
files using the following wildcard:
del *.exe
How can I do the opposite, i.e. delete all files that do not end in .exe
?
You can try this.
FOR /R [directory] %%F IN (*.*) DO IF NOT "%%~xF" == ".[extension]" DEL /F /S "%%F"
Or, if you have only one .exe file, it’s even simpler.
for %i in (*.*) do if not %i == FILE.EXE del %i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With