Reputation: 3151
print "copy ",meta_path + "/common/tools/meta to "+temp_dir+"/common/tools/meta"
shutil.copytree(meta_path + "/common/tools/meta", temp_dir+"/common/tools/meta")
this is python statement I use to copy a directory to different location, is there a way to copy paste with different permission during copy? I want to make the files in destination location with permission 777
os.chmod(temp_dir, stat.S_IRWXU)
did not work reliably after the copying is done.
thanks in advance.
Upvotes: 0
Views: 72
Reputation: 2378
That chmod
line will only change the permissions of the directory itself, not everything in it. For that, you can iterate over glob.glob(temp_dir + '/common/tools/meta/*')
or os.listdir(temp_dir + '/common/tools/meta/*')
, calling os.chmod
on each filename.
However, beware the dangers of making things world-writable/executable.
Upvotes: 1