Let's say I have these files that end in .MP4:
If I understand correctly, you want the names of the non-special files, minus the .MP4 extension.
First of all, I would use
find instead of
ls because it's easier to control and easier to parse the output. Either way, you'll end up with a list files separated by newline characters:
$ find . -name '*.MP4' -not -name '*_special.MP4'
Your sed command will work as is because the
$ in the pattern binds to the end of each line:
$ find . -name '*.MP4' -not -name '*_special.MP4' | sed -e 's/\.MP4$//'
basename command will actually do most of this for you; you don't even need
sed! The primary use of
basename is to remove the directory from the front of a path, but it also supports removing suffixes.
basename string [suffix]
basename only accepts a single word in the "string" position, so you need to use xargs to run it once for each file.
$ find . -name '*.MP4' -not -name '*_special.MP4' | xargs -I -name- basename -name- .MP4