foreach my $file (@files){ # *************************************************************************************** # * Discramble the file event * # *************************************************************************************** $File_MotionEvent = $file; $File_MotionEvent =~ s/$DIRECTORY//ox;; $File_MotionEvent =~ s/\///ox; $index = index($File_MotionEvent, "-",); $File_MotionEvent = substr($File_MotionEvent, 0, $index); mkdir("$DIRECTORY/$DATE/$File_MotionEvent"); #or die "Cannot mkdir newdir: $!"; # *************************************************************************************** # * Create the string for the new file location * # *************************************************************************************** print "\n"; $FileNewLocation = $file; print "$FileNewLocation\n"; # substitute/remove the directory name from the $NewFileLocation $FileNewFileLocation =~ s/$DIRECTORY//ox; print "$FileNewLocation\n"; # substitute/remove the \ at the beggining of the $NewFileLocation because $DIRECTORY doesn't contain the last slash $FileNewFileLocation =~ s/\///ox; print "$FileNewLocation\n"; print "\n";