当前位置:网站首页>从表中名称映射关系修改视频名称
从表中名称映射关系修改视频名称
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}: 不在表格中,请核实!")
边栏推荐
- [2022 广东省赛M] 拉格朗日插值 (多元函数极值 分治NTT)
- From monomer structure to microservice architecture, introduction to microservices
- It's hard to find a job when the industry is in recession
- VMware 虚拟化集群
- 24. Query table data (basic)
- flask返回文件下载
- logback1.3. X configuration details and Practice
- What is the use of entering the critical point? How to realize STM32 single chip microcomputer?
- Analysis of pointer and array written test questions
- [Yugong series] creation of 009 unity object of U3D full stack class in February 2022
猜你喜欢

Let the bullets fly for a while

synchronized 解决共享带来的问题

File upload of DVWA range

From monomer structure to microservice architecture, introduction to microservices

将 NFT 设置为 ENS 个人资料头像的分步指南

Pyqt5 development tips - obtain Manhattan distance between coordinates

wincc7.5下载安装教程(Win10系统)

hcip--mpls

"Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco

All the ArrayList knowledge you want to know is here
随机推荐
Yu Xia looks at win system kernel -- message mechanism
08- [istio] istio gateway, virtual service and the relationship between them
LDAP应用篇(4)Jenkins接入
Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
2. File operation - write
指针和数组笔试题解析
Vocabulary notes for postgraduate entrance examination (3)
Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
Data governance: data quality
String to leading 0
【T31ZL智能视频应用处理器资料】
The Vice Minister of the Ministry of industry and information technology of "APEC industry +" of the national economic and information technology center led a team to Sichuan to investigate the operat
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
Upgrade tidb operator
1204 character deletion operation (2)
Golang DNS 随便写写
The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
matplotlib. Widgets are easy to use
3. File operation 3-with
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products