1# Show nice ASCII ZHAW logo in Cyan
4 |___ /| | | | /\\ \ / /
5 / / | |__| | / \\ \ /\ / /
6 / / | __ | / /\ \\ \/ \/ /
7 / /__ | | | | / ____ \\ /\ /
8 /_____||_| |_|/_/ \_\\/ \/
10"@ -ForegroundColor Cyan
12# Show Header (Institute, Author, Date) in Yellow
14Institute: Institute of Signal Processing and Wireless Communications
15Author: Simon Moser (moss)
18"@ -ForegroundColor Yellow
20# Inform the user about the script's purpose in Gray
22This script copies the needed files from the ETHZ server to the local machine for further processing.
24"@ -ForegroundColor Gray
28## Define source directories
29$sourceDirs = (Read-Host "Enter source directories (separated by comma)").Split(",")
31# Validate user input (remove white spaces, check if directories exist)
32$sourceDirs = $sourceDirs | ForEach-Object {
34 if (!(Test-Path -Path $thisDir)) {
35 Write-Host "Directory not found: $thisDir"
41# Output source directories for user to check
42Write-Host "Source directories:"
47## Define target directory
48$targetDir = Read-Host "Enter target directory"
50# Validate user input (remove white spaces)
51$targetDir = $targetDir.Trim()
53## Output target directory for user to check
54Write-Host "Target directory: $targetDir"
57## Create target directory if it doesn't exist
58if (!(Test-Path -Path $targetDir)) {
60 # get confirmation from user
61 $createDir = Read-Host "Target directory does not exist. Do you want to create it? (y/n)"
62 if ($createDir -eq "y") {
64 New-Item -Path $targetDir -ItemType Directory > $null
65 Write-Host "Target directory created."
69 Write-Host "Error creating target directory. Exiting script."
74 Write-Host "Target directory not created. Exiting script."
80## Define participant numbers
81$participantNumbers = (Read-Host "Enter participant numbers (separated by comma)").Split(",")
83# Output participant numbers for user to check
84Write-Host "Participant numbers:"
88# Loop through each participant number
89foreach ($participantNumber in $participantNumbers) {
90 Write-Host "Processing participant: $participantNumber"
92 # List of files that need to be copied (relative to the source directory)
94 "\Processed\VICON\GaitSummary_YK\SonE_$participantNumber.mat",
95 "\Result\GaitSummaryIMU_SonE_$participantNumber.mat")
97 # Loop through each source directory
98 foreach ($sourceDir in $sourceDirs) {
100 # define source folder
101 $this_participant_source = $sourceDir + "\SonE_" + $participantNumber
103 # check if source folder exists
104 if (!(Test-Path -Path $this_participant_source)) {
105 Write-Host "Source folder not found: $this_participant_source"
109 # define target folder
110 $this_participant_target = $targetDir + "\SonE_" + $participantNumber
112 # create target folder if it doesn't exist
113 if (!(Test-Path -Path $this_participant_target)) {
115 New-Item -Path $this_participant_target -ItemType Directory > $null
118 Write-Host "Error creating directory: $this_participant_target, exiting script."
119 Read-Host "Press Enter to exit..."
124 # add all files to the file list that match $this_participant_source + "\RawData\ZM\*.BIN"
125 $binary_files = Get-ChildItem -Path "${this_participant_source}\RawData\ZM\*.BIN"
126 foreach ($binary_file in $binary_files) {
127 $files_to_copy += "\RawData\ZM\" + $binary_file.Name
130 Write-Host "Files to copy:"
134 # loop through each file to copy
135 foreach ($file in $files_to_copy) {
136 $this_file_source = $this_participant_source + $file
137 $this_file_target = $this_participant_target + $file
139 # continue if file doesn't exist
140 if (!(Test-Path -Path $this_file_source)) {
144 # create target directories if they don't exist
145 $this_file_target_dir = Split-Path -Path $this_file_target -Parent
146 if (!(Test-Path -Path $this_file_target_dir)) {
148 New-Item -Path $this_file_target_dir -ItemType Directory > $null
151 Write-Host "Error creating directory: $this_file_target_dir, exiting script."
152 Read-Host "Press Enter to exit..."
157 # continue if file already exists
158 if (Test-Path -Path $this_file_target) {
159 Write-Host "File already exists: $this_file_target"
165 Copy-Item -Path $this_file_source -Destination $this_file_target > $null
166 Write-Host "Copied $this_file_source to $this_file_target"
169 Write-Host "Error copying file: $this_file_source to $this_file_target"
176# Inform user that the script has finished
178Script finished. Press Enter to exit...
179"@ -ForegroundColor Green