adding rename and match scripts + removing raw shell
This commit is contained in:
parent
d6850e2f6f
commit
7136bd260a
19
match.rb
Normal file
19
match.rb
Normal 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
23
rename.py
Normal 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!")
|
Loading…
Reference in a new issue