How can I find files NOT matching a specific extension in Windows XP?
I need to find and delete all files in subdirectories that are not .SQL
files. I can't figure out how to search for <>.SQL
or !.SQL
in Windows Search.
Most of the solutions that I've seen here are to find specific extensions and do something with them. I'm looking for the opposite.
I don't know of a way to do it from Windows Search, but from the command line it is:
dir /s /b /a-d | findstr /v /r ".*\.sql"
- dir /s - recursive directory listing
- /b - bare listing, only file names (no directory size info etc. in the output)
- /a-d - filter by attributes, not directory (remove sub directories from the listing)
- | (pipe) - send the output of the directory listing to
- findstr - text search utility
- /v - only return lines that don't match
- /r - use regular expressions
- ".*.sql" - match anything any number of times followed by a dot followed by sql
In Windows 10 (I'm on version 1803) I use the Search box in File Explorer and type
*.* kind:-jpg
to find all files which are not jpg in my pictures folders (so, videos etc). Perhaps you should try
*.* kind:-sql
If you insist on using Windows search which doesn't have a native ability or support for such a feature, you could simply run it this way:
*.a OR *.b OR *.c OR *.d OR *.e OR *.f OR *.g OR *.h OR *.i OR *.j OR *.k OR *.l OR *.m OR *.n OR *.o OR *.p OR *.q OR *.r OR *.t OR *.u OR *.v OR *.w OR *.x OR *.y OR *.z
Following search will exclude all files with .s* extensions, while listing all others.
Perhaps there is a better way to do it, but this should work as well.