Unable to read some files found using os.walk

322 Views Asked by At

I am unable to read handful of files in my computer using python. Most of the folders in the computer look ok, but 200 or so files in the whole computer can't be read.

Code on a high level is doing this

for root, dirs, files in os.walk(r'C:\DR\SomeFolder'):
    for f in files:
        print(f, os.path.exists(root + os.sep + f))

os.path.exists() returns False for handful of files. Not sure why. I can't anything significantly different with these files or the directories.

I tried os.path.join() and open(). All of them fail to read the file.

Is it something weird like invisible characters or special characters in the file name or the directory?

1

There are 1 best solutions below

2
On

Yes. the user has permissions. I am running it as myself and is able to open the file in explorer