Skip to content

Commit

Permalink
Add clear downloads utility script
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Sep 5, 2024
1 parent 90713c2 commit 259e738
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions imageflow_core/clear_downloaded_images.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Get the script's directory (assumed to be imageflow_core)
$scriptDir = $PSScriptRoot

# Set the source and destination directories relative to the script location
$sourceDir = Join-Path $scriptDir "tests" "visuals"
$backupDir = Join-Path $sourceDir "_backup"

# Create the backup directory if it doesn't exist
if (-not (Test-Path $backupDir)) {
New-Item -ItemType Directory -Path $backupDir | Out-Null
Write-Host "Created backup directory: $backupDir"
}

# Get all PNG, JPG, and WebP files in the source directory
$files = Get-ChildItem -Path $sourceDir -File -Include "*.png", "*.jpg", "*.jpeg", "*.webp"

foreach ($file in $files) {
$destPath = Join-Path $backupDir $file.Name

# Check if the file already exists in the backup directory
if (Test-Path $destPath) {
Write-Host "Skipping $($file.Name) - already exists in backup directory"
} else {
# Move the file to the backup directory
Move-Item -Path $file.FullName -Destination $destPath
Write-Host "Moved $($file.Name) to backup directory"
}
}

Write-Host "Operation completed. Check $backupDir for moved files."
Write-Host "Source directory: $sourceDir"

0 comments on commit 259e738

Please sign in to comment.