If you want to remove your old files after changing their encoding you could use this:
INPUT="$1"
for i in *.mkv ; do
ffmpeg -i "$i" -bsf:v h264_mp4toannexb -sn -map 0:0 -map 0:1 -vcodec libx264 "$i.ts"
mv "$i.ts" "$i.mpg"
rm "$i"
sleep 3
done
*Based on Orsons solution. Also this will take hours to complete so you may wanna use it in a screen or tmux session to avoid interruptions.