Skip to content

Instantly share code, notes, and snippets.

@totetotetotem
Created June 10, 2017 06:16
Show Gist options
  • Save totetotetotem/8982849ecb2107596f9ce4393402fba3 to your computer and use it in GitHub Desktop.
Save totetotetotem/8982849ecb2107596f9ce4393402fba3 to your computer and use it in GitHub Desktop.
ディレクトリ内の.mtsファイルについて、最終更新時刻が10時以前だったら9時間のオフセットを足すプログラム
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