亚洲新天堂无码在线看_亚洲av无码一区二区三区秋霞_一级黄色片免费看_免费看一级一级人妻片

0722-3280566
首頁 > 新聞動(dòng)態(tài) > 行業(yè)新聞 >

# -*- coding: utf-8 -*-

程力專汽2024-12-30 23:46:580

# -*- coding: utf-8 -*-
import os
import csv
import shutil
import time

def move_files_according_to_record():
current_directory = os.path.dirname(os.path.abspath(__file__))
move_directory = os.path.join(current_directory, "移動(dòng)")
if not os.path.exists(move_directory):
os.mkdir(move_directory)

record_file_path = os.path.join(current_directory, "發(fā)布記錄.csv")
moved_file_path = os.path.join(current_directory, "移動(dòng)記錄.csv")

# 讀取已經(jīng)移動(dòng)的文件列表
moved_files = set()
if os.path.exists(moved_file_path):
with open(moved_file_path, "r", encoding="utf-8") as moved_file:
reader = csv.reader(moved_file)
for row in reader:
moved_files.add(row[0])

# 讀取發(fā)布記錄文件并移動(dòng)文件
with open(record_file_path, "r", encoding="utf-8", newline='') as record_file:
reader = csv.reader(record_file)
for row in reader:
filename = row[0]
source_file_path = os.path.join(current_directory, filename)
destination_file_path = os.path.join(move_directory, filename)
if os.path.exists(source_file_path) and filename not in moved_files:
try:
shutil.move(source_file_path, destination_file_path)
print(f"已移動(dòng)文件: {filename}")
# 記錄移動(dòng)成功的文件名
with open(moved_file_path, "a", encoding="utf-8", newline='') as moved_file:
writer = csv.writer(moved_file)
writer.writerow([filename])
except Exception as e:
print(f"移動(dòng)文件{filename}時(shí)出現(xiàn)錯(cuò)誤:{e}")
else:
print(f"未發(fā)現(xiàn){filename},移動(dòng)失敗。")

if __name__ == "__main__":
move_files_according_to_record()

 

# -*- coding: utf-8 -*-