Skip to content

Instantly share code, notes, and snippets.

@DSc-de
Last active June 11, 2022 11:38
Show Gist options
  • Save DSc-de/c393dbb43d0f6da813da99dc225d4412 to your computer and use it in GitHub Desktop.
Save DSc-de/c393dbb43d0f6da813da99dc225d4412 to your computer and use it in GitHub Desktop.
Python script to make all files in the current directory writable
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