On Unix or Mac:
How do you delete all files NOT of a specific type. Or How to copy all files of a specific type with the containing folder.
migrated from stackoverflow.com Oct 24 '12 at 12:02
This question came from our site for professional and enthusiast programmers.
Use find, e.g. to delete all files which are not .txt files:
WARNING: use this kind of command with care as it's easy to delete a lot of files unintentionally. Do a "dry run" first if you're not confident, e.g. to preview the above command: