Advertisement
Jexal

637d1ead-2b24-452d-a8a5-266a0bd7ec28

Mar 2nd, 2025
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Array of source directories:
  2. $sourceDirectories = @(
  3.     "C:\Users\Joel Taylor\Desktop\Adria Rae - Slender in White",
  4.     "C:\Users\Joel Taylor\Desktop\Adria Rae - Two Kinds of Rides",
  5.     "C:\Users\Joel Taylor\Desktop\Adria Rae - On the Course"
  6. )
  7.  
  8. # Setting the destination path:
  9. $destinationDirectory = "C:\Users\Joel Taylor\Desktop\Photos to Sort\Adria Rae"
  10.  
  11. # Function to log messages:
  12. function Log-Message {
  13.     param (
  14.         [string]$message,
  15.         [string]$type = "INFO"
  16.     )
  17.     $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
  18.     Write-Host "[$timestamp] [$type] $message"
  19. }
  20.  
  21. foreach ($sourceDirectory in $sourceDirectories) {
  22.     try {
  23.         Move-Item -Path $sourceDirectory -Destination $destinationDirectory -ErrorAction Stop
  24.         Write-Host "> Successfully moved " -ForegroundColor Green -NoNewline
  25.         Write-Host "'$sourceDirectory'" -ForegroundColor Cyan -NoNewline
  26.         Write-Host " to " -ForegroundColor Green -NoNewline
  27.         Write-Host "'$destinationDirectory'" -ForegroundColor Cyan
  28.         Log-Message "Moved $sourceDirectory to $destinationDirectory"
  29.     } catch {
  30.         Write-Host "> Error moving " -ForegroundColor Red -NoNewline
  31.         Write-Host "'$sourceDirectory'" -ForegroundColor Cyan -NoNewline
  32.         Write-Host " to " -ForegroundColor Red -NoNewline
  33.         Write-Host "'$destinationDirectory'" -ForegroundColor Cyan -NoNewline
  34.         Write-Host ": $_" -ForegroundColor Red
  35.         Log-Message "Failed to move $sourceDirectory: $_" "ERROR"
  36.     }
  37. }
  38.  
  39. # Opening the directory in its new location:
  40. Invoke-Item -Path $destinationDirectory
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement