Skip to content

Instantly share code, notes, and snippets.

@pandorica-opens
Created January 18, 2021 20:34
Show Gist options
  • Select an option

  • Save pandorica-opens/9c822c7ecc9b56d7a2a767f98412ade1 to your computer and use it in GitHub Desktop.

Select an option

Save pandorica-opens/9c822c7ecc9b56d7a2a767f98412ade1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import subprocess
print(sys.argv[1])
with open(sys.argv[1]) as file:
changed = file.read().replace('jane', 'jdoe')
file.seek(0)
original = file.read()
print(original)
print(changed)
for f, fo in zip(changed.split('\n'), original.split('\n')):
print(f)
print(fo)
try:
subprocess.run(["mv", fo, f])
except:
print('! file does not exist')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment