-
Notifications
You must be signed in to change notification settings - Fork 45
/
copy_files.py
36 lines (27 loc) · 1.13 KB
/
copy_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
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import shutil
import os
import shutil
def copy_files_except_extensions(src_dir, out_dir, excluded_extensions):
"""
Copy files from the source directory to the output directory, excluding files with specified extensions.
Args:
src_dir (str): The path to the source directory.
out_dir (str): The path to the output directory.
excluded_extensions (list): A list of file extensions to exclude.
Returns:
None
"""
for root, dirs, files in os.walk(src_dir):
for file in files:
if not any(file.endswith(ext) for ext in excluded_extensions):
src_path = os.path.join(root, file)
relative_path = os.path.relpath(src_path, src_dir)
dest_path = os.path.join(out_dir, relative_path)
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
shutil.copy2(src_path, dest_path)
src_directory = 'src/colibri'
out_directory = 'out/colibri'
excluded_extensions = ['.ts', '.js', '.log']
copy_files_except_extensions(src_directory, out_directory, excluded_extensions)
print("Files copied successfully!")