Question:
How can I read out filenames until the last occurrence of a character?
Answer:
In the first case, the following filenames (without extension) occur, and the text needed for further processing is highlighted.
0175-0001-01_03 and kdx-01_45-0001-05_02
The normal solution for the first case would be to perform a segmentation and then process the first hit.
This no longer works in the second case. The segmentation would return a list with 3 elements. However, the first element does not contain all the required text.
Solution is using a custom Python macro
Instead of segmentation, select custom macro and insert the following script:
idx = in_value.rfind("_")
return in_value[:idx]
This script returns the value before the last occurrence of _
If you only want to process the value after the last occurrence of _, use the following script:
idx = in_value.rfind("_")
return in_value[idx+1:]
To search for a different separator, replace the underscore in the line idx = in_value.rfind("_") with the corresponding alternative character.
Note:
If the separator is not found, the full original value is returned.