Skip to content

Instantly share code, notes, and snippets.

@lvisintini
Created September 27, 2017 10:26
Show Gist options
  • Save lvisintini/1622694de359d3a471e2858fa17fee6b to your computer and use it in GitHub Desktop.
Save lvisintini/1622694de359d3a471e2858fa17fee6b to your computer and use it in GitHub Desktop.
FlowEnergy statement filename format change
import os
import shutil
import datetime
PATH = '/home/lvisintini/Downloads/flowenergy'
def main():
new_names = {}
for dirpath, _, filenames in os.walk(PATH):
for f in filenames:
filename_data = f.replace('Statement- ', '')
day, month, year, extension = filename_data.split('.')
date = datetime.date(int(year) + 2000, int(month), int(day))
new_name = f'{date}.{extension}'
new_names[os.path.join(dirpath, f)] = os.path.join(dirpath, new_name)
for old_name, new_name in new_names.items():
shutil.copy2(old_name, new_name)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment