
Pythonで
・ファイルの更新日時を変更
できます!
コード
ここでは例として
・デスクトップ配下のファイル「aiueo.txt」の
・更新日時を変更
します。
※「2023年08月13日 19:55:14」から「2023年08月01日 09:00:00」へ変更します。
※デスクトップ上に下記コードを記載した「sample.py」を作成します。

import os
import datetime
# 対象ファイルのファイルパス
file_path = r'C:\Users\lunch\Desktop\aiueo.txt'
# 変更後の日時
last_write_time = datetime.datetime.strptime(
'2023-08-01 09:00:00', '%Y-%m-%d %H:%M:%S'
).timestamp()
# ファイルの更新日時を変更
os.utime(file_path, (last_write_time, last_write_time))
実行結果
ファイルの更新日時を変更できました。
※「2023年08月01日 09:00:00」へ変更できました。


参考
上記で使用した以下の詳細は、公式サイトをご確認ください。
●標準ライブラリ「datetime」モジュールの「datetime.strptime」
●標準ライブラリ「datetime」モジュールの「datetime.timestamp」
●標準ライブラリ「os」モジュールの「utime」