Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Created July 9, 2024 04:45
Show Gist options
  • Save jimdiroffii/92a76088987aa0eca29178ce40469c59 to your computer and use it in GitHub Desktop.
Save jimdiroffii/92a76088987aa0eca29178ce40469c59 to your computer and use it in GitHub Desktop.
PowerShell script to copy picture files, works for any file type, good for archiving stuff from a backup or drive dump
# PowerShell script to copy picture files
# Source and destination directories
$sourceDir = "C:\tmp\drivedump"
$destDir = "C:\tmp\picbackup"
# Check if destination directory exists, if not, create it
if (!(Test-Path -Path $destDir)) {
New-Item -ItemType Directory -Path $destDir
}
# Define popular picture file types from 2000-2018
$fileTypes = @("*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", "*.tiff")
# Copy each file type from the source to the destination
foreach ($fileType in $fileTypes) {
Get-ChildItem -Path $sourceDir -Filter $fileType -Recurse |
Copy-Item -Destination $destDir
}
# Output completion message
Write-Host "Copying of picture files complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment