adding rename and match scripts + removing raw shell

This commit is contained in:
christalib 2020-03-28 11:31:47 +01:00
parent d6850e2f6f
commit 7136bd260a
3 changed files with 42 additions and 0 deletions

19
match.rb Normal file
View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
ids = []
titles = []
res = []
File.open('ids.txt').each do |line|
ids << line
end
File.open('titles.txt').each do |t|
titles << t
end
ids.each do |id|
titles.each do |title|
res << "#{id}-#{title}" if ids.find_index(id) == titles.find_index(title)
end
end
puts res

23
rename.py Normal file
View file

@ -0,0 +1,23 @@
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!")

BIN
shell

Binary file not shown.