Sorry, I was not making myself clear.

What I mean is that some folders have subfolders that I don't have access to read. This causes the script to halt unexpectedly. i(dot)imgur(dot)com/5DBJh6K.png

As you can see, it stops at the first folder where I don't have full read permissions (the appdata folder in "agnar" is out of my spectrum).

Here's some pseudocode of approximately what I want:

if(can't read subfolder)
skip subfolder

Something like that. Or if that doesn't work, then:

if(can't read subfolder)
skip folder and write error

As it is now, the script completely halts as soon as it reaches an appdata folder.