Given a path to a file, c:\\xxx\\abc\\xyz\\fileName.jpg, how can I get the file\'s parent folder? In this example, I\'m looking for xyz. The number
c:\\xxx\\abc\\xyz\\fileName.jpg
xyz
If all your paths look the same like the one you provided:
print path.split('\\')[-2]