Advertisement
flurin4

rename_log.py

Jan 23rd, 2018
633
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. # In order to get the current time for the filename
  4. from datetime import datetime
  5. from pytz import timezone
  6. # In order to change the name of the file
  7. from shutil import move
  8.  
  9. # Get current time, find your timezone at https://stackoverflow.com/questions/13866926/python-pytz-list-of-timezones
  10. swissloc = timezone('Europe/Zurich')
  11. swisstime = datetime.now(swissloc)
  12. hour_now = swisstime.strftime('%Y-%m-%d_%H-%M-%S')
  13.  
  14. move('./test.txt', './test_' + hour_now + '.txt')
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement