my $errno = system("$cmd");
            $errno = $errno >> 8;
            if($errno) { die "-E- make_mkv encountered some errors with exit code $errno\n"; }
+           system("ls -l \"$srcpathname/\" > /dev/null"); # Make sure the video file is there
            # Fix the permissions
            system("chown $owner \"$video\"");
            system("chgrp $group \"$video\"");
            system("chmod $mode \"$video\"");
            # Remove the individual video files
            if(!defined $opt_k) { 
-               foreach $video (@{$videos{$ext}{$video}}) {
-                   system("rm -f $video");
+               foreach $srcvideo (@{$videos{$ext}{$video}}) {
+                   system("rm -f $srcvideo");
                }
            }
        }
 
 
     # We are ready to pick a destination folder to put the video in
     $dstdir = $dstpathname . "/" . $year;
-    $dstdirs[$dstdir] = 1;
+    $dstdirs{$dstdir} = 1;
     $dstfile = $dstdir . "/" . $year . "-" . $monthnum . "-" . $day;
 
     # Check for duplicate filenames at the destination