給NAS 網路磁碟伺服器 使用者俱樂部社團的執行檔





原始碼如下: (需安裝filedate模組)
import sys
import os
import datetime
import time
import filedate
def convert_file_created_time_to_modified_time(path):
f = filedate.File(path)
pp = f.get()
print('檔案路徑:', path)
print('修改日期:', pp['modified'])
print('建立日期:', pp['created'])
f.set(
**dict(pp, created=pp['modified'])
)
pp = f.get()
print('修改建立日期後資訊如下:')
print('建立日期:', pp['created'])
print()
app_dir = os.path.dirname(sys.executable)
print(app_dir)
all_dir = [d for d in os.listdir(app_dir) if os.path.isdir(d)]
print('找到的根目錄:')
for d in all_dir:
print(d)
input('按下Enter開始執行')
for dd in all_dir:
for r, d, n in os.walk(dd):
for f in n:
convert_file_created_time_to_modified_time(os.path.join(r, f))
input('按下Enter結束')