Aug-16-2023, 03:00 PM
(This post was last modified: Aug-16-2023, 03:00 PM by deanhystad.)
filenames = [ "BCY0649_PURANATTA_120X90MM__ Cyan.tif", "BCY0649_PURANATTA_120X90MM__ Black.tif", "BCY0649_PURANATTA_120X90MM__ Magenta.tif", "BCY0649_PURANATTA_120X90MM__ PANTONE 357 C.tif", "BCY0649_PURANATTA_120X90MM__ PANTONE 465 C.tif", "BCY0649_PURANATTA_120X90MM__ Yellow.tif", ] for name in filenames: parts = name.split(" ") if "PANTONE" in parts: print(" ".join(parts[parts.index("PANTONE") :])) else: print(parts[-1])This will not work if you can have color names like "Dark Blue", or if there is a different separator, or no separator, or if the color name is not at the end, or for a multitude of unexpected reasons.
You really need to provide more, different patterns or define the grammar used to make these names.