Updated to use os.walk instead of two different ways to get files and folders. Also using re rather than glob.