Maybe try to get just the filename and then rebuild the path with os.path.join which will use the correct character depending on the OS.
Also, in my opinion you should do some checks before, like “os.path.isfile(path)” or “os.path.exists(path)”, that will save you some trouble
[EDIT] You also have built-in functions in os module like os.path.normcase
I’m on Windows, see :
import os
import glob
folder = "C:/Users/pomme/test"
subfolders = glob.glob(folder+"/*")
print(folder)
for foldername in subfolders:
print(os.path.normcase(foldername))
Result
['C:/Users/pomme/test\\one', 'C:/Users/pomme/test\\two']
c:\users\pomme\test\one
c:\users\pomme\test\two
You can also fix the pathnames yourself by doing
filename.replace("\\","/")
filename.replace("\","/")