What I have:
import os import ntpath def fetch_name(filepath): return os.path.splitext(ntpath.basename(filepath))[0] a = u'E:\That is some string over here\news_20.03_07.30_10 .m2t' b = u'E:\And here is some string too\Logo_TimeBuffer.m2t.mpg' fetch_name(a) >>u'That is some string over here\news_20.03_07.30_10 ' # wrong! fetch_name(b) >>u'Logo_TimeBuffer.m2t' # wrong! What I need:
fetch_name(a) >>u'news_20.03_07.30_10 ' fetch_name(b) >>u'Logo_TimeBuffer'
.? Do you want to treat all three-character suffixes delimited by.as extensions?.bla.mpgas an extension. :P