Guest User

Untitled

a guest
Dec 18th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import shutil
  2. import datetime
  3. import os
  4. import fileinput
  5.  
  6. original_file = "\network\path\to\file"
  7.  
  8. def date_rename_file():
  9. todays_date = datetime.datetime.now()
  10. stripped_time = todays_date.strftime('%Y%m%d')
  11. shutil.copyfile(original_file, "\network\path\to\backupfolder\device_"+str(stripped_time)+".txt")
  12.  
  13. def device_id_replace():
  14. original_id = input("What device ID are you needing to replace?")
  15. new_id = input("What is the new device ID?")
  16. with open(original_file, 'w') as devicetxt:
  17. for line in devicetxt:
  18. print(line)
  19. if original_id in line:
  20. print("Found "+original_id)
  21.  
  22. date_rename_file()
  23. device_id_replace()
Add Comment
Please, Sign In to add comment