import os

folder = os.getcwd()

for root, dirs, files in os.walk(folder):

    # folders → 775
    for d in dirs:
        path = os.path.join(root, d)
        try:
            os.chmod(path, 0o775)
        except Exception as e:
            print("Folder error:", path, e)

    # files → 664
    for f in files:
        path = os.path.join(root, f)
        try:
            os.chmod(path, 0o664)
        except Exception as e:
            print("File error:", path, e)

print("Done setting permissions.")
