-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransfer_data.py
More file actions
71 lines (51 loc) · 2.42 KB
/
transfer_data.py
File metadata and controls
71 lines (51 loc) · 2.42 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import shutil
import sys
source_data_directory = "/Users/abhinavpappu/Library/CloudStorage/OneDrive-UniversityofVirginia/Abhinav-Greg/Anika_VonFrey_Data/P2 - Current/Density"
target_data_directory = "data/P2_Current"
# Create target directory if it doesn't exist
os.makedirs(target_data_directory, exist_ok=True)
# iterating through the 4 densities
for density in os.listdir(source_data_directory):
# Skip .DS_Store and other hidden files
if density.startswith('.'):
continue
source_path = os.path.join(source_data_directory, density)
target_path = os.path.join(target_data_directory, density)
# Skip if source_path is not a directory
if not os.path.isdir(source_path):
continue
print(f"Processing density: {density}")
print(f"Target path: {target_path}")
# Create target density directory
os.makedirs(target_path, exist_ok=True)
# iterating through radial and Radial and Spatial
for dir_name in os.listdir(source_path):
if dir_name.startswith('.'):
continue
temp_path = source_path
if "Aggregate" in dir_name:
continue
if "Radial" in dir_name or "Spatial" in dir_name:
temp_path = os.path.join(temp_path, dir_name)
for file in os.listdir(temp_path):
if file.startswith('.'):
continue
trial = ["Trial_1", "Trial_2", "Trial_3"]
vfs = ["3.61", "4.08", "4.31", "4.56"]
for t in trial:
for vf in vfs:
if f"{vf}_{t}" in file:
source_file = os.path.join(temp_path, file)
target_file = os.path.join(target_path, vf, t, file)
# Create target directory if it doesn't exist
os.makedirs(os.path.dirname(target_file), exist_ok=True)
# Copy the file
try:
shutil.copy2(source_file, target_file)
print(f"Copied {source_file} to {target_file}")
except Exception as e:
print(f"Error copying {source_file}: {str(e)}")
else:
continue
print("Data transfer completed!")