- #!/usr/bin/env python
- import os, os.path, sys, stat
- folder_list = sys.argv[1:]
- folder_mask = ['bin', 'Virtualbox VMs']
- for a in folder_mask:
- if a in folder_list:
- folder_list.remove(a)
- for i in folder_list:
- for root, dirnames, filenames in os.walk(i):
- temp = dirnames[0:]
- for a in temp:
- if (a[0] == '.') and (a in folder_mask):
- dirnames.remove(a)
- continue
- os.chmod(os.path.join(root,a), stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
- for a in filenames:
- if a[0] == '.':
- continue
- os.chmod(os.path.join(root,a), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
- #该片段来自于http://www.codesnippet.cn/detail/270820135336.html
来源: http://www.codesnippet.cn/detail/270820135336.html