Files
SkyArtShop/sync-uploads.ps1

30 lines
1.4 KiB
PowerShell
Executable File

# Sync uploaded images between live site and localhost
# Run this script to sync images uploaded on the live site to your development environment
$liveUploads = "C:\inetpub\wwwroot\skyartshop\wwwroot\uploads\images"
$devUploads = "E:\Documents\Website Projects\Sky_Art_Shop\wwwroot\uploads\images"
Write-Host "🔄 Syncing uploads from live site to localhost..." -ForegroundColor Cyan
# Copy new files from live to dev
Get-ChildItem -Path $liveUploads -File | ForEach-Object {
$devFile = Join-Path $devUploads $_.Name
if (-not (Test-Path $devFile) -or $_.LastWriteTime -gt (Get-Item $devFile).LastWriteTime) {
Copy-Item $_.FullName $devFile -Force
Write-Host " ✅ Copied: $($_.Name)" -ForegroundColor Green
}
}
# Copy new files from dev to live (if you upload locally)
Get-ChildItem -Path $devUploads -File | ForEach-Object {
$liveFile = Join-Path $liveUploads $_.Name
if (-not (Test-Path $liveFile) -or $_.LastWriteTime -gt (Get-Item $liveFile).LastWriteTime) {
Copy-Item $_.FullName $liveFile -Force
Write-Host " ✅ Copied to live: $($_.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n✨ Sync complete!" -ForegroundColor Green
Write-Host "📊 Total images in dev: $((Get-ChildItem $devUploads).Count)" -ForegroundColor Cyan
Write-Host "📊 Total images in live: $((Get-ChildItem $liveUploads).Count)" -ForegroundColor Cyan