Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Array of source directories:
- $sourceDirectories = @(
- "C:\Users\Joel Taylor\Desktop\Adria Rae - Slender in White",
- "C:\Users\Joel Taylor\Desktop\Adria Rae - Two Kinds of Rides",
- "C:\Users\Joel Taylor\Desktop\Adria Rae - On the Course"
- )
- # Setting the destination path:
- $destinationDirectory = "C:\Users\Joel Taylor\Desktop\Photos to Sort\Adria Rae"
- # Function to log messages:
- function Log-Message {
- param (
- [string]$message,
- [string]$type = "INFO"
- )
- $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
- Write-Host "[$timestamp] [$type] $message"
- }
- foreach ($sourceDirectory in $sourceDirectories) {
- try {
- Move-Item -Path $sourceDirectory -Destination $destinationDirectory -ErrorAction Stop
- Write-Host "> Successfully moved " -ForegroundColor Green -NoNewline
- Write-Host "'$sourceDirectory'" -ForegroundColor Cyan -NoNewline
- Write-Host " to " -ForegroundColor Green -NoNewline
- Write-Host "'$destinationDirectory'" -ForegroundColor Cyan
- Log-Message "Moved $sourceDirectory to $destinationDirectory"
- } catch {
- Write-Host "> Error moving " -ForegroundColor Red -NoNewline
- Write-Host "'$sourceDirectory'" -ForegroundColor Cyan -NoNewline
- Write-Host " to " -ForegroundColor Red -NoNewline
- Write-Host "'$destinationDirectory'" -ForegroundColor Cyan -NoNewline
- Write-Host ": $_" -ForegroundColor Red
- Log-Message "Failed to move $sourceDirectory: $_" "ERROR"
- }
- }
- # Opening the directory in its new location:
- Invoke-Item -Path $destinationDirectory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement