-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFiles.ps1
122 lines (101 loc) · 5.77 KB
/
Files.ps1
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Write-Output "
███████╗██╗██╗ ███████╗ ██████╗ ██╗ █████╗ ██████╗███████╗███╗ ███╗███████╗███╗ ██╗████████╗
██╔════╝██║██║ ██╔════╝ ██╔══██╗██║ ██╔══██╗██╔════╝██╔════╝████╗ ████║██╔════╝████╗ ██║╚══██╔══╝
█████╗ ██║██║ █████╗ ██████╔╝██║ ███████║██║ █████╗ ██╔████╔██║█████╗ ██╔██╗ ██║ ██║
██╔══╝ ██║██║ ██╔══╝ ██╔═══╝ ██║ ██╔══██║██║ ██╔══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║
██║ ██║███████╗███████╗ ██║ ███████╗██║ ██║╚██████╗███████╗██║ ╚═╝ ██║███████╗██║ ╚████║ ██║
╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝
"
# Optimized Version of the Script
function CopyFolder($sourcePath, $destinationPath) {
try {
if (Test-Path $sourcePath) {
Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force
Write-Host "📁 Folder copied successfully to $destinationPath 🎉"
} else {
throw "❌ Source folder not found at $sourcePath"
}
} catch {
Write-Host "An error occurred: $_" -ForegroundColor Red
Write-Host "Please check the paths and try again." -ForegroundColor Yellow
}
}
function MoveFolder($sourceFolder, $destinationPath) {
try {
$username = $env:USERNAME
$userDestinationPath = "C:\Users\$username\$destinationPath"
if (!(Test-Path $userDestinationPath)) {
Write-Host "❌ Destination folder not found for user $username"
} else {
Move-Item -Path $sourceFolder -Destination $userDestinationPath -Force
Write-Host "✅ Folder moved to $destinationPath for user $username"
}
} catch {
Write-Host "❌ An error occurred: $_.Exception.Message"
}
}
# Copying the .config folder
$currentUsername = $env:USERNAME
$sourcePath = ".\.config"
$destinationPath = "C:\Users\$currentUsername\"
CopyFolder $sourcePath $destinationPath
# Moving the PowerShell and WindowPowerShell folders
MoveFolder ".\PowerShell" "Documents"
MoveFolder ".\WindowsPowerShell" "Documents"
# Moving the Window Terminal settings.json file
$destinationPath = "AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
MoveFolder ".\Window-Terminal\settings.json" $destinationPath
# Orginal Code
# try {
# $currentUsername = $env:USERNAME
# $sourcePath = ".\.config"
# $destinationPath = "C:\Users\$currentUsername\"
# try {
# if (Test-Path $sourcePath) {
# Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force
# Write-Host "📁 Folder Copyed successfully to $destinationPath 🎉"
# } else {
# throw "❌ Source folder not found at $sourcePath"
# }
# } catch {
# Write-Host "An error occurred: $_" -ForegroundColor Red
# Write-Host "Please check the paths and try again." -ForegroundColor Yellow
# }
# }
# catch {
# Write-Host "❌ An error occurred: $_.Exception.Message"
# }
# # Moving the PowerShell and WindowPowerShell Config Files
# try {
# # Get the username of the currently logged-in user
# $username = $env:USERNAME
# # Check if the Documents directory exists for the user
# $documentsPath = "C:\Users\$username\Documents"
# if (!(Test-Path $documentsPath)) {
# Write-Host "📁 Documents directory not found for user $username"
# } else {
# # Move the 'PowerShell' and 'WindowPowerShell' folders to the Documents directory
# Move-Item -Path ".\PowerShell" -Destination $documentsPath -Force
# Move-Item -Path ".\WindowsPowerShell" -Destination $documentsPath -Force
# Write-Host "✅ Folders moved to Documents directory for user $username"
# }
# } catch {
# Write-Host "❌ An error occurred: $_.Exception.Message"
# }
# # config File for Window Terminal
# try {
# # Get the username of the currently logged-in user
# $username = $env:USERNAME
# # Check if the user's folder exists
# $destinationPath = "C:\Users\$username\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
# if (!(Test-Path $destinationPath)) {
# Write-Host "❌ Destination folder not found for user $username"
# } else {
# # Move the 'settings.json' file to the destination folder
# $sourceFile = ".\Window-Terminal\settings.json" # Replace with the actual path of your 'settings.json' file
# Move-Item -Path $sourceFile -Destination $destinationPath -Force
# Write-Host "✅ 'settings.json' file moved to destination folder for user $username"
# }
# } catch {
# Write-Host "❌ An error occurred: $_.Exception.Message"
# }