小白用 python 版的批量重命名
#!/usr/bin/env python3
# 凡人修仙传( 1401-1500 ) 1.mp3 => 凡人修仙传 0001.mp3
#
import os
import sys
path = "/home/ht/下载 /"
try:
>>>>prefix = sys.argv[1]
except IndexError:
>>>>print("usage: python3
rename_pad.py argv1")
>>>>sys.exit(1)
for filename in os.listdir(path):
>>>>num = filename[:-4].split()[-1]
>>>>suffix = filename[-4:]
>>>>num = num.zfill(4)
>>>>new_filename = prefix + "_" + num + suffix
>>>>os.rename(os.path.join(path, filename), os.path.join(path, new_filename))