当前位置:网站首页>从表中名称映射关系修改视频名称
从表中名称映射关系修改视频名称
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}: 不在表格中,请核实!")
边栏推荐
- Nft智能合约发行,盲盒,公开发售技术实战--拼图篇
- 从 CSV 文件迁移数据到 TiDB
- Step by step guide to setting NFT as an ens profile Avatar
- MFC sends left click, double click, and right click messages to list controls
- wincc7.5下载安装教程(Win10系统)
- Wireshark grabs packets to understand its word TCP segment
- Let the bullets fly for a while
- 华为云OBS文件上传下载工具类
- vulnhub hackme: 1
- How to use information mechanism to realize process mutual exclusion, process synchronization and precursor relationship
猜你喜欢
[cloud native] teach you how to build ferry open source work order system
Zhong Xuegao, who cannot be melted, cannot escape the life cycle of online celebrity products
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
Database basic commands
将 NFT 设置为 ENS 个人资料头像的分步指南
Golang DNS 随便写写
wincc7.5下载安装教程(Win10系统)
Learn Arduino with examples
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
好用的TCP-UDP_debug工具下载和使用
随机推荐
Database basic commands
Binary tree creation & traversal
leetcode刷题 (5.28) 哈希表
LDAP应用篇(4)Jenkins接入
Circular reference of ES6 module
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
备份与恢复 CR 介绍
What are the ways to download network pictures with PHP
[Yugong series] creation of 009 unity object of U3D full stack class in February 2022
C language custom type: struct
Uibehavior, a comprehensive exploration of ugui source code
Pyqt5 development tips - obtain Manhattan distance between coordinates
Convolution, pooling, activation function, initialization, normalization, regularization, learning rate - Summary of deep learning foundation
【T31ZL智能视频应用处理器资料】
logback1.3. X configuration details and Practice
[research materials] 2022 China yuancosmos white paper - Download attached
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
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
Webrtc series-h.264 estimated bit rate calculation