当前位置:网站首页>从表中名称映射关系修改视频名称
从表中名称映射关系修改视频名称
2022-07-06 08:19:00 【不求大富大贵只求富可敌国】
题目:
有一个voiceFile文件夹内的50个后缀是*.pcm文件名称都需要修改,文件后缀保留,修改的名称参考:rename.csv中的影射关系,第一列是文件原来的名字,第二列是文件现在的名字,每行都有影射关系(第一列老名字,第二列是对应的新名字),要求将文件夹的文件都名称都改成B列的名字
解决方法:
import os
import pandas as pd
from log_utils import Log_util
# csv文件路径
csv_path=r"C:\Users\xdjiang6\Desktop\rename.csv"
# 视频文件夹路径
video_path=r"D:\xdjiang\voiceFile"
# 读取csv文件
res=pd.read_csv(csv_path)
# 第一列是文件原来的名字(老名字)
old_list=res.values[:,0]
# 第二列是文件现在的名字(对应的新名字)
new_list=res.values[:,1]
# 把读取的新名称与老名称组合成字典
name_list=dict(zip(old_list,new_list))
# 读取视频文件夹所有的视频文件
aaa=os.listdir(video_path)
#判断视频文件名是否==csv提取的老文件名,如果相等,把视频文件名修改为新文件名
for i in aaa:
if i in name_list.keys():
os.rename(os.path.join(video_path,i),os.path.join(video_path,name_list[i]))
Log_util.mlog.debug(f"{
i}: 视频名称修改完毕!")
else:
Log_util.mlog.error(f"{
i}: 不在表格中,请核实!")
边栏推荐
- C语言 - 位段
- 3. File operation 3-with
- 灰度升级 TiDB Operator
- Online yaml to CSV tool
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
- [t31zl intelligent video application processor data]
- LDAP应用篇(4)Jenkins接入
- vulnhub hackme: 1
- 从 TiDB 集群迁移数据至另一 TiDB 集群
猜你喜欢
A Closer Look at How Fine-tuning Changes BERT
Understanding of law of large numbers and central limit theorem
Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
【MySQL】数据库的存储过程与存储函数通关教程(完整版)
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
Let the bullets fly for a while
2. File operation - write
化不掉的钟薛高,逃不出网红产品的生命周期
Configuring OSPF load sharing for Huawei devices
Wireshark grabs packets to understand its word TCP segment
随机推荐
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
使用 TiUP 升级 TiDB
NFT smart contract release, blind box, public offering technology practice -- jigsaw puzzle
JS select all and tab bar switching, simple comments
Restore backup data on S3 compatible storage with tidb lightning
hcip--mpls
Migrate data from a tidb cluster to another tidb cluster
【云原生】手把手教你搭建ferry开源工单系统
21. Delete data
On why we should program for all
Nacos Development Manual
Résumé des diagrammes de description des broches de la série ESP
flask返回文件下载
远程存储访问授权
VMware 虚拟化集群
Data governance: misunderstanding sorting
ESP系列引脚說明圖匯總
ESP series pin description diagram summary
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
从 CSV 文件迁移数据到 TiDB