Often times in scripting on a Linux box, you end up passing around the full path to a resource (it’s messy coding tbh).
This is great until you want to use just the filename in something.
Here’s a simple Python method that takes a full filename with path and grabs just the filename.
def findFileName (self, fileNameWithPath):
splitStr = fileNameWithPath
strList = splitStr.rsplit(‘/’, 1)
fileName = strList[len(strList) – 1]