问题描述
我在下面创建了基本脚本,该脚本扫描目录中的wav文件,并根据文件属性将它们复制到嵌套目录中。
spark-redshift
最初,我使用标准的"""
Script that copies data from Peersonic RPA3 into directory
using file name,date and time
"""
import datetime as dt
import os
import shutil
import time
from pathlib import Path
# Function to check if survey is dusk or dawn
def duskdawn(file):
filetime = dt.datetime.fromtimestamp(os.path.getmtime(file))
if file_time.time() > dt.time(12):
return "Dusk"
else:
return "Dawn"
def file_date(file):
return time.strftime('%d.%m.%Y',time.localtime(os.path.getmtime(file)))
def client(file):
return file.name[0:3]
client_lst = ['IES','DEC','TEP']
# Directory of files
path = "/Volumes/BATrecorder/WAVFILES.DIR"
for entry in os.scandir(path):
source = entry.path
perm = os.stat(entry).st_mode
client_name = (client(entry))
if entry.name.endswith(".WAV"):
if client_name in client_lst:
client_name = client_name
else:
client_name = "unkNown"
destination = f"/Volumes/Seagate Exp/Work 2020/Bat recordings/{client_name}/{file_date(entry)}/{duskdawn(entry)}"
Path(destination).mkdir(parents=True,exist_ok=True)
shutil.copy2(source,destination)
函数,此方法运行良好。但是,我需要保留原始文件元数据,因此需要使用shutil.copy()
来代替。当我使用此代码时,出现以下错误:
shutil.copy2()
这是怎么回事导致此问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)