Skip to content

Instantly share code, notes, and snippets.

@mannysz
Created June 7, 2017 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannysz/14d4373df359ee4ee9759c870f8690cf to your computer and use it in GitHub Desktop.
Save mannysz/14d4373df359ee4ee9759c870f8690cf to your computer and use it in GitHub Desktop.
Stripping directory and extension from file name
import os
FILENAME = "/path/to/my/filewith.ext"
base_name = os.path.basename(FILENAME)
without_ext = os.path.splitext(base_name)[0]
print(without_ext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment