Python recursive change uid and gid (chown) of directory


/ Published in: Python
Save to your folder(s)

as you run chown -R user:group dir


Copy this code and paste it in your HTML
  1. def _chown(path, uid, gid):
  2. os.chown(path, uid, gid)
  3. for item in os.listdir(path):
  4. itempath = os.path.join(path, item)
  5. if os.path.isfile(itempath):
  6. os.chown(itempath, uid, gid)
  7. elif os.path.isdir(itempath):
  8. os.chown(itempath, uid, gid)
  9. self._chown(itempath, uid, gid)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.