-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_stuff.py
More file actions
20 lines (17 loc) · 864 Bytes
/
copy_stuff.py
File metadata and controls
20 lines (17 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import shutil
# Define the source and destination directories
src_dir = r"C:\Users\Jakda\Box\CoganLab\BIDS-1.3_SentenceOld"
dst_dir = r"C:\Users\Jakda\Box\CoganLab\BIDS-1.4_SentenceRep"
for dirpath, dirnames, filenames in os.walk(src_dir):
for filename in filenames:
# Check if the filename contains the keyword "channels"
if "channels" in filename:
# Construct full file path
src_file = os.path.join(dirpath, filename)
relative_path = os.path.relpath(dirpath, src_dir)
dst_file = os.path.join(dst_dir, relative_path, filename)
# Check if the destination directory exists
if os.path.exists(os.path.dirname(dst_file)):
# Copy the file to the destination directory, overwriting any existing file
shutil.copy2(src_file, dst_file)