当前位置:网站首页>从表中名称映射关系修改视频名称
从表中名称映射关系修改视频名称
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}: 不在表格中,请核实!")
边栏推荐
- Sanzi chess (C language)
- Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development
- Mobile Test Engineer occupation yyds dry goods inventory
- "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
- hcip--mpls
- The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
- Hill sort c language
- National economic information center "APEC industry +": economic data released at the night of the Spring Festival | observation of stable strategy industry fund
- [2022 广东省赛M] 拉格朗日插值 (多元函数极值 分治NTT)
- Fibonacci sequence
猜你喜欢

IP lab, the first weekly recheck

21. Delete data

Golang DNS write casually

Configuring OSPF load sharing for Huawei devices

化不掉的钟薛高,逃不出网红产品的生命周期

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

Hungry for 4 years + Ali for 2 years: some conclusions and Thoughts on the road of research and development

ESP系列引脚說明圖匯總

Pyqt5 development tips - obtain Manhattan distance between coordinates

Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
随机推荐
matplotlib. Widgets are easy to use
The resources of underground pipe holes are tight, and the air blowing micro cable is not fragrant?
使用 BR 恢复 S3 兼容存储上的备份数据
使用 BR 备份 TiDB 集群数据到兼容 S3 的存储
C language custom type: struct
Data governance: Data Governance under microservice architecture
Secure captcha (unsafe verification code) of DVWA range
备份与恢复 CR 介绍
Epoll and IO multiplexing of redis
Migrate data from SQL files to tidb
Webrtc series-h.264 estimated bit rate calculation
Chinese Remainder Theorem (Sun Tzu theorem) principle and template code
PHP - Common magic method (nanny level teaching)
TiDB备份与恢复简介
String to leading 0
NFT smart contract release, blind box, public offering technology practice -- contract
Remote storage access authorization
The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
LDAP应用篇(4)Jenkins接入
1204 character deletion operation (2)