<commit_before>#!/usr/local/bin/python
# -*- coding: utf-8 -*-

""" Rename file.

Rename file to update time.
"""

import os
import time
import re

FILE_DIR = 'save'
BACKUP_DIR = 'rename_bk'
RENAME_PAT = '201[0-9][0-1][0-9][0-3][0-9].gif$'

# Use logging

def main():
    """ main module."""
    files = os.listdir(FILE_DIR)
    # Make backup dir
    # Separate to module
    for f in files:
        # Confirm as target file.
        file_path = os.path.join(FILE_DIR, f)
        org_file_name = os.path.basename(file_path)
        if re.match(RENAME_PAT, org_file_name):
            print 'Already changed file[{0}]'.format(org_file_name)
            continue
        # Get file name
        f_stat = os.stat(file_path)
        update_epoc = f_stat.st_mtime
        update_time = time.gmtime(update_epoc)
        file_name = '{year}{month}{day}.gif'.format(
            year=update_time.tm_year,
            month=str(update_time.tm_mon).zfill(2),
            day=str(update_time.tm_mday).zfill(2))
        refile_path = os.path.join(FILE_DIR, file_name)
        # Check file name
        if os.path.exists(refile_path):
            print 'Exist same file name[{0}].'.format(file_path)
            continue
        print file_path
        # Backup
        # Rename 
            # os.rename()

if __name__ == '__main__':
    main()<commit_msg>Made rename script.<commit_after>#!/usr/local/bin/python
# -*- coding: utf-8 -*-

""" Rename file.

Rename file to update time.
"""

import os
import time
import re
import shutil
import logging

FILE_DIR = 'save'
BACKUP_DIR = 'rename_bk'
RENAME_PAT = '201[0-9][0-1][0-9][0-3][0-9].gif$'

# Use logging


def main():
    """ main module."""
    logging.basicConfig(format='[%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    files = os.listdir(FILE_DIR)
    # Make backup dir
    # Separate to module
    for f in files:
        set_backup()
        file_path = os.path.join(FILE_DIR, f)
        org_file_name = os.path.basename(file_path)
        if re.match(RENAME_PAT, org_file_name):
            logging.info('Already changed file[{0}]'.format(org_file_name))
            continue
        # Get file name
        f_stat = os.stat(file_path)
        update_epoc = f_stat.st_mtime
        update_time = time.gmtime(update_epoc)
        file_name = '{year}{month}{day}.gif'.format(
            year=update_time.tm_year,
            month=str(update_time.tm_mon).zfill(2),
            day=str(update_time.tm_mday).zfill(2))
        refile_path = os.path.join(FILE_DIR, file_name)
        # Check file name
        if os.path.exists(refile_path):
            logging.info('Exist same file name[{0}].'.format(file_path))
            continue
        org_file_path = os.path.join(FILE_DIR, org_file_name)
        backup_file_path = os.path.join(BACKUP_DIR, org_file_name)
        shutil.copy(org_file_path, backup_file_path)
        shutil.copymode(org_file_path, backup_file_path)
        shutil.copystat(org_file_path, backup_file_path)
        new_file_path = os.path.join(FILE_DIR, file_name)
        os.rename(org_file_path, new_file_path)


def set_backup():
    """Set up backup directory."""
    if not os.path.exists(BACKUP_DIR):
        os.mkdir(BACKUP_DIR)

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.12775061124694376, 'fraction_numerical': 0.011002444987775062, 'mean_word_length': 2.515574650912997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3657554', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1137, 'n_words': 213}