Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change permissions for folder, all subfolders, and all files

Tags:

python

I am trying to call shutil.rmtree(some_folder), but it is causing an error that another process is using some file in the subtree. This is not the case, so I'm assuming permissions are not set correctly.

How can I change the permissions of all subfolders and files under some root to writeable, so I can call shutil.rmtree and get rid of them?

Thanks

like image 683
kbm Avatar asked Nov 17 '25 17:11

kbm


1 Answers

On a platform with the chmod command available, you could do this:

subprocess.call(['chmod', '-R', '+w', some_folder])

Assuming that some_folder is a string that is the full-path to the folder you want to modify.

like image 165
multipleinterfaces Avatar answered Nov 20 '25 07:11

multipleinterfaces



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!