spellbook/lecture name changer.py
2022-03-22 11:45:11 +10:00

22 lines
557 B
Python

import os
# the first date is at the end because of the way python sorts lists
# hd1.mp4 is larger than hd1(*).mp4
dates = ["07-25", "07-28", "08-01", "08-12", "08-15", "08-19", "08-22", "07-22"]
course = "comp4610"
# hold all file names
f = []
# walk through files in current directory
for (_, _, files) in os.walk("./"):
# hd(1) is the format of files we want
files = filter(lambda x: x[0] == 'h', files)
f.extend(files)
break
for i, f in enumerate(sorted(files)):
name = course + "-" + dates[i] + ".mp4"
os.rename(f, name)