22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
import os
|
|
from datetime import datetime
|
|
from Comics.settings import BASE_OUTPUT
|
|
|
|
def list_files_with_times(root_folder):
|
|
# 遍历主文件夹下的子文件夹和文件
|
|
for dirpath, dirnames, filenames in os.walk(root_folder):
|
|
for filename in filenames:
|
|
file_path = os.path.join(dirpath, filename)
|
|
# 获取文件的最后修改时间
|
|
modification_time = os.path.getmtime(file_path)
|
|
# 格式化时间
|
|
# formatted_time = datetime.fromtimestamp(modification_time).strftime('%Y-%m-%d %H:%M:%S')
|
|
remove_time = datetime.fromtimestamp(modification_time).strftime('%Y-%m-%d')
|
|
if remove_time == "2024-10-28":
|
|
formatted_time = datetime.fromtimestamp(modification_time).strftime('%Y-%m-%d %H:%M:%S')
|
|
os.remove(file_path)
|
|
print(f"File: {file_path} | Last Modified: {formatted_time}")
|
|
|
|
# 使用示例
|
|
root_folder = os.path.join(BASE_OUTPUT, 'CBZ/') # 替换为实际文件夹路径
|
|
list_files_with_times(root_folder) |