471,330 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

chmod directories recursively

Hello!

As far as I can see os.chmod() doesn't adjust permissions on directories
recusively. Is there any other possibility to achieve this aim except for
calling os.system('chmod -R /dir') directly?

Thanks,
Fabian
Jul 17 '07 #1
2 9182
Fabian Steiner wrote:
Hello!

As far as I can see os.chmod() doesn't adjust permissions on directories
recusively. Is there any other possibility to achieve this aim except for
calling os.system('chmod -R /dir') directly?

Thanks,
Fabian
Check out os.path.walk.

James
Jul 17 '07 #2
Jennifer Thacher wrote:
Fabian Steiner wrote:
>As far as I can see os.chmod() doesn't adjust permissions on directories
recusively. Is there any other possibility to achieve this aim except for
calling os.system('chmod -R /dir') directly?

Thanks,
Fabian

Check out os.path.walk.
Thanks for your advice. This pointed me into the right direction.
For those who are interested the function passed to os.path.walk looks like
this:

def _chownRecursive(arg, dirname, fnames):
os.chown(dirname, arg[0], arg[1])
for file in fnames:
os.chown(os.path.join(dirname, file), arg[0], arg[1])
Fabian
Jul 17 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Daniel | last post: by
6 posts views Thread by Ask Josephsen | last post: by
2 posts views Thread by Joseph S. | last post: by
5 posts views Thread by rbt | last post: by
3 posts views Thread by Kamen TOMOV | last post: by
47 posts views Thread by frizzle | last post: by
3 posts views Thread by Rik | last post: by
3 posts views Thread by misceverything | last post: by
1 post views Thread by lawrence k | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.