我有一个文件列表:Wav16.ogg,Wav17.ogg。。。Wav76.ogg
我想转换成:a65.ogg,b72.ogg。。。b32.ogg公司
到目前为止,我的情况是:
import os
import numpy as np
OldContent = [i.strip().split() for i in open("OTWGYNmp3/Wav#.txt").readlines()]
oldName = np.asarray(OldContent)
NewContent = [i.strip().split() for i in open("OTWGYNmp3/Key#.txt").readlines()]
newName = np.asarray(NewContent)
这就是我努力实现但不确定如何前进的要点:
for i in len(newName):
os.rename(oldName[i], newName[i])
我环顾四周,看到了不同的答案,但它们都涉及到通过某种因素更改名称,而不是用任意名称替换:Rename multiple files in a directory in Python
找到了解决方案:https://unix.stackexchange.com/questions/250828/script-for-renaming-files-using-text-file-containing-alternate-file-names
抱歉,我不知道bash会更有效
给定名为
orig
和new
的文件中的文件名:如果
echo
看起来正常,请将其移除。你知道吗给定样本输入:
原始
新建
示例输出为:
相关问题 更多 >
编程相关推荐