views:

48

answers:

3

Hey,

I'm curious how to copy the permission from directory to another. Any idea?

Thanks

+4  A: 

shutil.copymode should help you out. From the documentation:

shutil.copymode(src, dst)

Copy the permission bits from src to dst. The file contents, owner, and group are unaffected. src and dst are path names given as strings.

I tested this in Ubuntu Jaunty using Python 2.6.2 and it worked for me.

Manoj Govindan
+1  A: 

Since you mentionned python, I assume you are looking for

shutil.copymode(src, dst)

See the documentation on shutil

Rod
A: 

Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.

Vasileios Lourdas