It's not work fo me:
target_dir = "a/b/c/d/e/" os.makedirs(target_dir,0777)
os.chmod work only for last directory ...
It's not work fo me:
target_dir = "a/b/c/d/e/" os.makedirs(target_dir,0777)
os.chmod work only for last directory ...
You can use os.walk
to traverse directories. (Below not tested, experiment it yourself)
for r, d, f in os.walk(path): os.chmod(r, 0o777)
ghostdog74's answer almost works, but it tries to walk into the directory before it chmods it. So the real answer is less elegant:
os.chmod(path , 0o777) for root,dirs,_ in os.walk(path): for d in dirs : os.chmod(os.path.join(root,d) , 0o777)
One line version for this is:
list(map(lambda x: os.chmod(x[0], 0o775), os.walk(target_dir)))