Skip to content

Instantly share code, notes, and snippets.

@MareArts
Created May 2, 2019 09:57
Show Gist options
  • Save MareArts/29364dbd31306a04ddd2266b7a012561 to your computer and use it in GitHub Desktop.
Save MareArts/29364dbd31306a04ddd2266b7a012561 to your computer and use it in GitHub Desktop.
import os
def splitPathFileExt(fullName):
base=os.path.basename(fullName)
split_name = os.path.splitext(base)
#print(split_name)
FilePath = str[:str.rfind('/')]
FileName = split_name[0]
FileExt = split_name[1]
#print(FilePath, FileName, FileExt)
return FilePath, FileName, FileExt
str = '/Users/Folder2/MyFolder/test_data/test/someFileName.json'
FilePath, FileName, FileExt = splitPathFileExt(str)
print(FilePath)
print(FileName)
print(FileExt)
#/Users/Folder2/MyFolder/test_data/test
#someFileName
#.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment