I wrote a script that recursively reads the contents of a folder and outputs the names and permissions of the files contained in that folder.
If the folder contains a subfolder, what I'd like it do to is open the subfolder and do the same check for the files inside that subfolder.
Unfortunately right now when I loop through the contents of the folder a subfolder is recognized as a file, rather than a folder and so my script doesn't know to open the subfolder. I am not sure what I am doing wrong. I am using the function is_dir() to check whether the contents of the folder are files or subfolders but apparently in that loop all folders and files don't satisfy that condition and is_dir() returns false for all of them.
How can I circumvent this?