Code:
#!/bin/bash
if test x"$1" = x"-h" -o x"$1" = x"--help" -o x"$1" = x"" ; then
cat <<EOF
Usage: mpls-to-avs <mplsfile> <sourcefilter>
Help:
-h, --help print this message
EOF
exit 1
fi
if [ "$2" = "ffms2" ] ; then
SCRIPTFUNC="FFVideoSource"
elif [ "$2" = "lsmash" ] ; then
SCRIPTFUNC="LwLibavVideoSource"
fi
BASICNAME=$(sed 's/M2TS/M2TS\n/g' "$1" | perl -ne 'print scalar reverse;' | cut -c1-9 | perl -ne 'print scalar reverse;')
echo $BASICNAME | sed 's/M2TS/M2TS\n/g' | grep M2TS | sed -e 's/ //g' -e 's/M2TS/.m2ts/g' | awk '{printf("(\"%s\") ++ \\\n",$1)};' | sed -e "s/^/$SCRIPTFUNC/g" -e '$ s/ ++ \\//' | todos > "$1".avs
This is assuming that .mpls files are simple playlists and don't do weird chapter jumping stuff, and that all of the .m2ts files the .mpls refers to actually work. At any rate, it does show which files the .mpls refers to, so it still has some value, I guess.
Although the easiest way to deal with it is just by running the playlist through mkvmerge and working with the single file it gives you.