当前位置:网站首页>从表中名称映射关系修改视频名称
从表中名称映射关系修改视频名称
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}: 不在表格中,请核实!")
边栏推荐
- Summary of MySQL index failure scenarios
- [Yugong series] February 2022 U3D full stack class 010 prefabricated parts
- Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
- Step by step guide to setting NFT as an ens profile Avatar
- 24. Query table data (basic)
- Circuit breaker: use of hystrix
- ESP系列引脚說明圖匯總
- 升级 TiDB Operator
- Migrate data from SQL files to tidb
- 649. Dota2 Senate
猜你喜欢

在 uniapp 中使用阿里图标

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Golang DNS write casually

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

National economic information center "APEC industry +": economic data released at the night of the Spring Festival | observation of stable strategy industry fund

It's hard to find a job when the industry is in recession

Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data

Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center

ESP系列引脚说明图汇总

A Closer Look at How Fine-tuning Changes BERT
随机推荐
Analysis of Top1 accuracy and top5 accuracy examples
Migrate data from CSV files to tidb
[cloud native] teach you how to build ferry open source work order system
[research materials] 2021 live broadcast annual data report of e-commerce - Download attached
Flash return file download
A Closer Look at How Fine-tuning Changes BERT
Permutation and combination function
Restore backup data on S3 compatible storage with br
在 uniapp 中使用阿里图标
JS select all and tab bar switching, simple comments
Let the bullets fly for a while
C language - bit segment
Mobile Test Engineer occupation yyds dry goods inventory
[secretly kill little partner pytorch20 days -day01- example of structured data modeling process]
leetcode刷题 (5.29) 哈希表
It's hard to find a job when the industry is in recession
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
649. Dota2 Senate
Day29-t77 & t1726-2022-02-13-don't answer by yourself