diff --git a/1_Install.ps1 b/1_Install.ps1 index 246a29b..34e184f 100644 --- a/1_Install.ps1 +++ b/1_Install.ps1 @@ -151,10 +151,40 @@ function Update-Scripts { if ($applyChoice -eq "Y" -or $applyChoice -eq "y") { Write-Host "Installing updates..." -ForegroundColor Cyan - # Copy files from the extracted directory directly - Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + # Copy all content from extracted directory to the root, preserving structure + Write-Host "Copying files from $($extractedDir.FullName) to $updateScriptDir..." -ForegroundColor Cyan + + # First, copy all individual files at the root level + Get-ChildItem -Path $extractedDir.FullName -File | Where-Object { $_.Name -ne ".gitignore" -and $_.Name -ne ".gitattributes" } | ForEach-Object { $destPath = Join-Path -Path $updateScriptDir -ChildPath $_.Name - Copy-Item -Path $_.FullName -Destination $destPath -Recurse -Force + Copy-Item -Path $_.FullName -Destination $destPath -Force + Write-Host " Copied file: $($_.Name)" -ForegroundColor DarkGray + } + + # Then, copy all directories (but not .git) + Get-ChildItem -Path $extractedDir.FullName -Directory | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + $dirName = $_.Name + $destDirPath = Join-Path -Path $updateScriptDir -ChildPath $dirName + + # Create destination directory if it doesn't exist + if (-not (Test-Path $destDirPath -PathType Container)) { + New-Item -Path $destDirPath -ItemType Directory -Force | Out-Null + } + + # Copy all files from this subdirectory + Get-ChildItem -Path $_.FullName -Recurse -File | ForEach-Object { + $relPath = $_.FullName.Substring($extractedDir.FullName.Length + 1) + $destFilePath = Join-Path -Path $updateScriptDir -ChildPath $relPath + $destFileDir = Split-Path -Parent $destFilePath + + # Ensure directory exists + if (-not (Test-Path $destFileDir -PathType Container)) { + New-Item -Path $destFileDir -ItemType Directory -Force | Out-Null + } + + Copy-Item -Path $_.FullName -Destination $destFilePath -Force + Write-Host " Copied: $relPath" -ForegroundColor DarkGray + } } Write-Host "Update completed successfully!" -ForegroundColor Green diff --git a/2_ConfigUpdate.ps1 b/2_ConfigUpdate.ps1 index b43f518..0fb787d 100644 --- a/2_ConfigUpdate.ps1 +++ b/2_ConfigUpdate.ps1 @@ -151,10 +151,40 @@ function Update-Scripts { if ($applyChoice -eq "Y" -or $applyChoice -eq "y") { Write-Host "Installing updates..." -ForegroundColor Cyan - # Copy files from the extracted directory directly - Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + # Copy all content from extracted directory to the root, preserving structure + Write-Host "Copying files from $($extractedDir.FullName) to $updateScriptDir..." -ForegroundColor Cyan + + # First, copy all individual files at the root level + Get-ChildItem -Path $extractedDir.FullName -File | Where-Object { $_.Name -ne ".gitignore" -and $_.Name -ne ".gitattributes" } | ForEach-Object { $destPath = Join-Path -Path $updateScriptDir -ChildPath $_.Name - Copy-Item -Path $_.FullName -Destination $destPath -Recurse -Force + Copy-Item -Path $_.FullName -Destination $destPath -Force + Write-Host " Copied file: $($_.Name)" -ForegroundColor DarkGray + } + + # Then, copy all directories (but not .git) + Get-ChildItem -Path $extractedDir.FullName -Directory | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + $dirName = $_.Name + $destDirPath = Join-Path -Path $updateScriptDir -ChildPath $dirName + + # Create destination directory if it doesn't exist + if (-not (Test-Path $destDirPath -PathType Container)) { + New-Item -Path $destDirPath -ItemType Directory -Force | Out-Null + } + + # Copy all files from this subdirectory + Get-ChildItem -Path $_.FullName -Recurse -File | ForEach-Object { + $relPath = $_.FullName.Substring($extractedDir.FullName.Length + 1) + $destFilePath = Join-Path -Path $updateScriptDir -ChildPath $relPath + $destFileDir = Split-Path -Parent $destFilePath + + # Ensure directory exists + if (-not (Test-Path $destFileDir -PathType Container)) { + New-Item -Path $destFileDir -ItemType Directory -Force | Out-Null + } + + Copy-Item -Path $_.FullName -Destination $destFilePath -Force + Write-Host " Copied: $relPath" -ForegroundColor DarkGray + } } Write-Host "Update completed successfully!" -ForegroundColor Green diff --git a/3_ConfigAfterNextcloud.ps1 b/3_ConfigAfterNextcloud.ps1 index d2b4002..85b233c 100644 --- a/3_ConfigAfterNextcloud.ps1 +++ b/3_ConfigAfterNextcloud.ps1 @@ -151,10 +151,40 @@ function Update-Scripts { if ($applyChoice -eq "Y" -or $applyChoice -eq "y") { Write-Host "Installing updates..." -ForegroundColor Cyan - # Copy files from the extracted directory directly - Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + # Copy all content from extracted directory to the root, preserving structure + Write-Host "Copying files from $($extractedDir.FullName) to $updateScriptDir..." -ForegroundColor Cyan + + # First, copy all individual files at the root level + Get-ChildItem -Path $extractedDir.FullName -File | Where-Object { $_.Name -ne ".gitignore" -and $_.Name -ne ".gitattributes" } | ForEach-Object { $destPath = Join-Path -Path $updateScriptDir -ChildPath $_.Name - Copy-Item -Path $_.FullName -Destination $destPath -Recurse -Force + Copy-Item -Path $_.FullName -Destination $destPath -Force + Write-Host " Copied file: $($_.Name)" -ForegroundColor DarkGray + } + + # Then, copy all directories (but not .git) + Get-ChildItem -Path $extractedDir.FullName -Directory | Where-Object { $_.Name -ne ".git" } | ForEach-Object { + $dirName = $_.Name + $destDirPath = Join-Path -Path $updateScriptDir -ChildPath $dirName + + # Create destination directory if it doesn't exist + if (-not (Test-Path $destDirPath -PathType Container)) { + New-Item -Path $destDirPath -ItemType Directory -Force | Out-Null + } + + # Copy all files from this subdirectory + Get-ChildItem -Path $_.FullName -Recurse -File | ForEach-Object { + $relPath = $_.FullName.Substring($extractedDir.FullName.Length + 1) + $destFilePath = Join-Path -Path $updateScriptDir -ChildPath $relPath + $destFileDir = Split-Path -Parent $destFilePath + + # Ensure directory exists + if (-not (Test-Path $destFileDir -PathType Container)) { + New-Item -Path $destFileDir -ItemType Directory -Force | Out-Null + } + + Copy-Item -Path $_.FullName -Destination $destFilePath -Force + Write-Host " Copied: $relPath" -ForegroundColor DarkGray + } } Write-Host "Update completed successfully!" -ForegroundColor Green