做到這一點的方法是在兩個步驟中重命名它們:
一個 - > 1 乙 - > 2
1 - >乙 2 - >一個
我用下面的代碼隨機更名視頻文件:
import os
import random
randlist = random.sample(range(14), 14)
os.rename("clip0.mp4", "video0.mp4")
os.rename("clip1.mp4", "video1.mp4")
os.rename("clip2.mp4", "video2.mp4")
os.rename("clip3.mp4", "video3.mp4")
os.rename("clip4.mp4", "video4.mp4")
os.rename("clip5.mp4", "video5.mp4")
os.rename("clip6.mp4", "video6.mp4")
os.rename("clip7.mp4", "video7.mp4")
os.rename("clip8.mp4", "video8.mp4")
os.rename("clip9.mp4", "video9.mp4")
os.rename("clip10.mp4", "video10.mp4")
os.rename("clip11.mp4", "video11.mp4")
os.rename("clip12.mp4", "video12.mp4")
os.rename("clip13.mp4", "video13.mp4")
os.rename("video0.mp4", "clip" + str(randlist[0]) + ".mp4")
os.rename("video1.mp4", "clip" + str(randlist[1]) + ".mp4")
os.rename("video2.mp4", "clip" + str(randlist[2]) + ".mp4")
os.rename("video3.mp4", "clip" + str(randlist[3]) + ".mp4")
os.rename("video4.mp4", "clip" + str(randlist[4]) + ".mp4")
os.rename("video5.mp4", "clip" + str(randlist[5]) + ".mp4")
os.rename("video6.mp4", "clip" + str(randlist[6]) + ".mp4")
os.rename("video7.mp4", "clip" + str(randlist[7]) + ".mp4")
os.rename("video8.mp4", "clip" + str(randlist[8]) + ".mp4")
os.rename("video9.mp4", "clip" + str(randlist[9]) + ".mp4")
os.rename("video10.mp4", "clip" + str(randlist[10]) + ".mp4")
os.rename("video11.mp4", "clip" + str(randlist[11]) + ".mp4")
os.rename("video12.mp4", "clip" + str(randlist[12]) + ".mp4")
os.rename("video13.mp4", "clip" + str(randlist[13]) + ".mp4")