Created
June 10, 2017 06:16
-
-
Save totetotetotem/8982849ecb2107596f9ce4393402fba3 to your computer and use it in GitHub Desktop.
ディレクトリ内の.mtsファイルについて、最終更新時刻が10時以前だったら9時間のオフセットを足すプログラム
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 subprocess | |
import datetime | |
files = os.listdir('.') | |
for fileName in files: | |
if fileName.split(".")[-1] == "mts": | |
dt = datetime.datetime.fromtimestamp(os.stat(fileName).st_mtime) | |
if int(dt.strftime('%H')) < 10: | |
print dt | |
m = dt.strftime('%m') | |
d = dt.strftime('%d') | |
h = str(int(dt.strftime('%H')) + 9) | |
mi = dt.strftime('%M') | |
time = m+d+h+mi | |
print time | |
subprocess.call(["touch", "-t", dt.strftime(time), fileName]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment