Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
cleanup_SonE.ps1
Go to the documentation of this file.
1# Show nice ASCII ZHAW logo in Cyan
2Write-Host @"
3 ______ _ _ __ __
4 |___ /| | | | /\\ \ / /
5 / / | |__| | / \\ \ /\ / /
6 / / | __ | / /\ \\ \/ \/ /
7 / /__ | | | | / ____ \\ /\ /
8 /_____||_| |_|/_/ \_\\/ \/
9
10"@ -ForegroundColor Cyan
11
12# Show Header (Institute, Author, Date) in Yellow
13Write-Host @"
14Institute: Institute of Signal Processing and Wireless Communications
15Author: Simon Moser (moss)
16Date: 2024-07-05
17
18"@ -ForegroundColor Yellow
19
20# Inform the user about the script's purpose in Gray
21Write-Host @"
22This script will delete all processed data files in the current folder and its subfolders. Only the files given from ETHZ will remain.
23
24"@ -ForegroundColor Gray
25
26# Specify the folder path here
27$folderPath = Get-Location
28
29# Output the folder path to the user in Green
30Write-Host @"
31The script will delete all processed data files in the following folder:
32$folderPath
33
34"@ -ForegroundColor Green
35
36# Ask the user for confirmation before proceeding in Red
37$confirmation = Read-Host "Do you wish to proceed? (Y/N)"
38if ($confirmation -ne 'Y') {
39 Write-Host "Operation aborted by the user." -ForegroundColor Red
40 Read-Host "Press Enter to exit..."
41 exit
42}
43
44# Deleting all .log files in the specified folder
45Get-ChildItem -Path $folderPath -Filter "*.log" -File | Remove-Item -Force
46# Navigating through each subfolder starting with "SonE_"
47Get-ChildItem -Path $folderPath -Directory | Where-Object { $_.Name -like "SonE_*" } | ForEach-Object {
48 $currentFolder = $_.FullName
49
50 # Output the currently processed folder in Magenta
51 Write-Host "Processing folder: $currentFolder" -ForegroundColor Magenta
52
53 # Deleting all .log files in the current subfolder
54 Get-ChildItem -Path $currentFolder -Filter "*.log" -File | Remove-Item -Force
55
56 # Deleting the 'temp' directories inside
57 Get-ChildItem -Path $currentFolder -Directory | Where-Object { $_.Name -like "temp" } | Remove-Item -Recurse -Force
58
59 # Deleting all .json files in the current subfolder
60 Get-ChildItem -Path $currentFolder -Filter "*.json" -File | Remove-Item -Force
61
62 # Deleting all .mat files
63 Get-ChildItem -Path $currentFolder -Filter "*.mat" -File | Remove-Item -Force
64
65 # Deleting the 'gait_parameters' directories inside
66 Get-ChildItem -Path $currentFolder -Directory | Where-Object { $_.Name -like "gait_parameters" } | Remove-Item -Recurse -Force
67}
68
69Write-Host "Operation completed successfully." -ForegroundColor Green
70Read-Host "Press Enter to exit..."