Created
July 9, 2024 04:45
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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