-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFind_files.py
23 lines (18 loc) · 881 Bytes
/
Find_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
root_dir_path = "/home/vipikuma/Documents"
new_file_path = os.path.join(root_dir_path, "../all_files")
def copyfile(src, dest):
with open(src, "rb") as source_file:
with open(dest, "wb") as destination_file:
destination_file.write(source_file.read())
def CopyAllFiles(root_dir_path, new_file_path, skip_hidden=True):
os.makedirs(new_file_path, exist_ok=True)
for root, dirs, files in os.walk(root_dir_path):
if not root.split("/")[-1].startswith("."):
for file in files:
old_file, new_file = os.path.join(root_dir_path, root, file), os.path.join(new_file_path, file)
print("Copying file: %s into %s" % (old_file, new_file_path))
copyfile(old_file, new_file)
return True
if CopyAllFiles(root_dir_path, new_file_path):
print("Done with copying all the Files")