You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
smol_scriptz/rename.py

23 lines
616 B

from os import makedirs, rename, walk
from os.path import exists, join
matched = open("matched.txt", "r")
videos = []
vid_path = 'vids/'
done_path = 'done/'
if not exists(done_path):
makedirs(done_path)
for (dirpath, dirnames, filenames) in walk(vid_path):
videos.extend(filenames)
for line in matched:
idx = [int(s) for s in line.split("-") if s.isdigit()]
for video in videos:
if str(idx[0]) in video:
try:
rename(join(vid_path + video), join(done_path + line.strip('\n') + ".mp4"))
except ValueError:
print("err")
print("done!")