Created
March 8, 2019 07:14
-
-
Save YUChoe/c319d0111944f76a9b940ae36e7ae842 to your computer and use it in GitHub Desktop.
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 time | |
start_timestamp = 1550587841 | |
for serial in os.listdir('.'): | |
for fn in os.listdir(serial): | |
ctime = os.stat(os.path.join(serial, fn)).st_ctime | |
if ctime > start_timestamp: | |
date_in_filename = fn.split('_')[0] | |
date_in_file_ctime = time.strftime('%Y-%m-%d', time.localtime(ctime)) | |
if date_in_filename != date_in_file_ctime: | |
profer_name = fn.replace(date_in_filename, date_in_file_ctime) | |
# fix error | |
src = os.path.join(serial, fn) | |
dst = os.path.join(serial, profer_name) | |
os.rename(src, dst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment