Last active
June 11, 2022 11:38
-
-
Save DSc-de/c393dbb43d0f6da813da99dc225d4412 to your computer and use it in GitHub Desktop.
Python script to make all files in the current directory writable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
import stat | |
def MakeFilesWritable(workingDir='.', silent=False): | |
numOfFiles = 0 | |
for dirpath, dirnames, filenames in os.walk(workingDir): | |
for filename in filenames: | |
path = os.path.join(dirpath, filename) | |
os.chmod(path, stat.S_IWRITE) | |
numOfFiles = numOfFiles + 1 | |
if (not silent): | |
print(f'Number of modified files: {numOfFiles}') | |
if __name__ == '__main__': | |
MakeFilesWritable() | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment