From what I'm understanding, you have a PDFE task automation folder monitor, set up to the USB3 hard disk target folder, that runs two tasks. The first edits the files metadata and makes use of the above script to extract the related parts from the filename. The second task renames the files and also uses the same script to generate the new filename.
Not related for the problem, but why are you using the script in the rename task, if you already have the same filename parts saved to the metadata fields? In the rename expression you only need to refer to these custom fields, filled by the first metadata edit task. From the screenshot you attached, the data seems to be the same.
Anyway, does the problem only occurs in the generation of the new filename, or you are also getting empty, or trimmed, metadata fields from the edit metadata task?
Do you get to see this problem if you manually use the rename tool, from the batch tools, against the original files in the network drive? Just select a batch of these files and start the rename tool with the same rename expression. You don't need to run the tool. Just check if the problem shows in the tool new file names preview panel.
is it possibel that the Metagas not reddy write when the rename prozess start ?
The tasks are run in sequence and the next tasks uses the data precessed from the previous, so that should not be happening.