Python Glob without the whole path - only the filename

user825286 picture user825286 · Sep 7, 2011 · Viewed 86k times · Source

Is there a way I can use glob on a directory, to get files with a specific extension, but only the filename itself, not the whole path?

Answer

Tom Zych picture Tom Zych · Sep 7, 2011

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