Python Glob without the whole path - only the filename Python Glob without the whole path - only the filename python python

Python Glob without the whole path - only the filename


Use os.path.basename(path) to get the filename.


This might help someone:

names = [os.path.basename(x) for x in glob.glob('/your_path')]


map(os.path.basename, glob.glob("your/path"))

Returns an iterable with all the file names and extensions.