I need to process linux file with multiple parts in the name like:
abc.def.gh.bz2
bz2 is the real extension, I need to get abc.def.gh
Can anyone tell me an elegant way to do this in python?
Thank you very much.
Use os.path.splitext
:
import os.path
os.path.splitext("abc.def.gh.bz2") # -> ("abc.def.gh", ".bz2")