Utkarsh Utkarsh - 1 year ago 84
Python Question

Recursively read through a folder tree and determine which folders have files

I've written a program to look through images inside a folder and extract the embedded EXIF data. Currently I'm using the code below to get paths for all the files inside a folder, the variable 'folder_name' is input by the user. The list created is then used by the program to cycle through all the images.

file_names = glob(join(expanduser('~'),'Desktop',folder_name,'*'))

Now I want to add a bit of functionality, that is the ability to look through a folder tree and return only the folders with images/files in them. This list could then be passed into the bit of code above to do the rest. I just need a pointer as to where to look to develop this.

Also how could I select and output just the image files, using
on the file path didn't work due to case sensitivity.

Answer Source

You can work around case-sensitivity by applying the .lower() string method to both strings before comparing them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download