Script to compare partial filenames in two folders and delete duplicates

Background: I use a TV tuner card to capture OTA video files (.mpeg) and then my Plex Media Server automatically optimizes the files (transcodes for better playback) and places them in a new directory. I have another Plex Library pointing to the new location for the optimized .mp4 files. This results in two folders containing files with the same name except for the file extension. My goal is to run a script every x number of minutes/hours to delete the original .mpeg files if the Plex server has already optimized them. I'm familiar with crontab well enough to set the script to run periodically but cannot figure out how to create the script to compare/delete the files.

Example;

Original video files:

/mnt/Plex/DVR/Original/
episode1mmddyyyy.mpeg
episode2mmddyyyy.mpeg
episode3mmddyyyy.mpeg

Optimized video files:

/mnt/Plex/DVR/Optimized/
episode1mmddyyyy.mp4
episode2mmddyyyy.mp4
episode3mmddyyyy.mp4

The script would compare files in the two directories (minus the file extensions) and delete all files in /mnt/Plex/DVR/Original/ that match. In the example above all files in /mnt/Plex/DVR/Original/ would be deleted to save space on the hard drive.

Any insight is appreciated.

Hi Shaky, Please try

orig=Original
orig_ext=*.mpeg
opti=Optimized
opti_ext=*.mp4

for i in $orig/$orig_ext
do
original_file=`basename ${i%.mpeg}`
        for l in $opti/$opti_ext
        do
                optimized_file=`basename ${l%.mp4}`
                if [[ "$original_file" == "$optimized_file" ]]; then
                echo "file $optimized_file match with $original_file."
                rm "$i"
                echo "Original File $i removed."
                fi
done
done

Try(untested)

cd /mnt/Plex/DVR/Optimized
for FN in *
  do FNORG=../Original/${FN%.mp4}.mpeg
     [ -f $FNORG ] && echo rm $FNORG
  done

Remove the echo if happy.