I know this is a little late, but I just stumbled upon the same problem and came up with a different solution. Perhaps someone looking at this will prefer this method.
Since my API was used exclusively on a Linux server, and since removal would be a relatively rare occurrence for me, I depended on the find linux command to help me.
# LINUX ONLY cmd = "find {0} -iwholename '{1}'".format(basepath, caseInsensitivePath) with os.popen(cmd) as f: caseSensitivePath = f.read()[:-1] # -1 to remove the '\n' # error if more than 1 line if caseSensitivePath.find('\n') != -1: print "Found multiple results including: \n", caseSensitivePath msg = "[!]ERROR Could not delete {0}. Multiple case-sensitive results exist".format(caseInsensitivePath) raise Exception(msg) else: return caseSensitivePath
basepath is the base search path. I would recommend finding a way to use something more precise than root '/'. In my case, I already had a list of paths in the synchronization folder, so I was able to perform the comparison as follows:
caseInsensitivePath = caseInsensitivePath.lower()
caseInsensitivePath is the way to go.
source share