Mr.Glaurung Mr.Glaurung - 11 days ago 5
Bash Question

find command with two different patterns

I have a huge directory with video files and subtitles, now I usually have 3 different subtiles files which is incorrect.

videofilename.srt
videofilename.en.srt
videofilename.sv.srt


English subtitles followed by english subtitles (again) and then swedish. Now my video player will not identify all three since it's two different standards (with and without language).

So I want to delete all files that has videofilename.srt but how the heck do I create a find command for that??

find . -type f -name '*[^\...]\.srt'


Doesn't seems to work.

Help?

Answer

You can use -regex in find to find files without language part:

find . -regex '\./[^.]*\.srt$'

./videofilename.srt

If you want to ignore all *.en.srt and *.sv.srt then use:

find . -name '*.srt' -not \( -name '*.en.srt' -o -name '*.sv.srt' \)

./videofilename.srt
Comments