Cli
Remove All Files with Certain Extension in Folder

How to remove all files in a directory with a certain extension

In this case we want to remove all files with the extension .jpg

In our current folder I have these files

├── a.jpg
├── b.jpg
├── c.jpg
├── d.png
├── somemovie.mp4
└── someothermovie.mp5

And after running

find . -type f -name '*.jpg' -exec rm -f {} +

I am left with

.
├── d.png
├── somemovie.mp4
└── someothermovie.mp5

If you wanted to exclude certain files you could use client;

find . -type f \( -name '*.jpg' ! -name 'exclude.jpg' ! -name 'another_exclude.jpg' \) -exec rm -f {} +