-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (33 loc) · 1.34 KB
/
main.py
File metadata and controls
35 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import shutil
def search_and_copy(src_dirs, dst_dir):
copied = False
file_names = []
with open("files.txt", "a+") as f:
f.seek(0)
file_names = f.readlines()
file_names = [x.strip() for x in file_names]
for src_dir in src_dirs:
for subdir, dirs, files in os.walk(src_dir):
for file in files:
file_path = subdir + os.sep + file
if file.endswith(".mp4"):
dst_file_path = os.path.join(dst_dir, file)
if file not in file_names:
shutil.copy(file_path, dst_dir)
f.write(file + "\n")
copied = True
if not copied:
all_files_copied = True
for src_dir in src_dirs:
for subdir, dirs, files in os.walk(src_dir):
for file in files:
if file.endswith(".mp4"):
dst_file_path = os.path.join(dst_dir, file)
if not os.path.exists(dst_file_path):
all_files_copied = False
if all_files_copied:
print("You already copied those videos.")
src_dirs = ['F:\\Videos-test\\test1', 'F:\\Videos-test\\test2']
dst_dir = 'F:\\Videos-test\\output'
search_and_copy(src_dirs, dst_dir)