Rename multiple files in Row_Inserting server event

I have a problem with my code. What I do is upload multiple images from the input and add a code that I generate to the name at the beginning.
In code it works, but the problem I have is that in the first image it adds the code at the beginning and in the second image it only leaves the name.
What am I doing wrong?

function Row_Inserting($rsold, &$rsnew)
{
    if ($rsnew["p_h_1"] != "") 
       { 
           $prefix = date("YmdHis");
           $extension = strtolower(substr($rsnew['p_h_1'], -4));
           $ext_nom = strtolower(substr($rsnew['p_h_1'], 0,-4));
           $new_image=$prefix."_".$ext_nom.$extension;
           $rsnew["p_h_1"] = $new_image; 
       }

    return true;
}

The saved result is as follows:
20220208223443_living_1_wallpapers.jpg##zenbook.pngBut it would have to be like this:
20220208223443_living_1_wallpapers.jpg##20220208223443_zenbook.pngI hope you can help me
Thanks

This might help: How to rename multiple files and displayed it vertically (v2022).

Thanks a lot