Created
September 27, 2017 10:26
-
-
Save lvisintini/1622694de359d3a471e2858fa17fee6b to your computer and use it in GitHub Desktop.
FlowEnergy statement filename format change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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