Created
January 15, 2023 17:43
-
-
Save moshen/9eea9c1a3bcd29b8119ff8337d7f83c2 to your computer and use it in GitHub Desktop.
Powershell script to copy Steam screenshots folders from one drive to another, for backing up screenshots or migrating to a new drive
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
param( | |
[string]$source_drive_letter, | |
[string]$destination_drive_letter | |
) | |
if ([string]::IsNullOrEmpty($source_drive_letter)) | |
{ | |
Write-Output "No source_drive_letter argument provided" | |
exit | |
} | |
if ($source_drive_letter.Length -gt 1) | |
{ | |
Write-Output "source_driver_letter argument longer than 1 character" | |
exit | |
} | |
$source_drive_letter = $source_drive_letter.ToUpper(); | |
if (-Not (Test-Path -Path "${source_drive_letter}:\")) | |
{ | |
Write-Output "source_drive_letter '$source_drive_letter' does not exist" | |
exit | |
} | |
if ([string]::IsNullOrEmpty($destination_drive_letter)) | |
{ | |
Write-Output "No destination_drive_letter argument provided" | |
exit | |
} | |
if ($destination_drive_letter.Length -gt 1) | |
{ | |
Write-Output "destination_driver_letter argument longer than 1 character" | |
exit | |
} | |
$destination_drive_letter = $destination_drive_letter.ToUpper() | |
if (-Not (Test-Path -Path "${destination_drive_letter}:\")) | |
{ | |
Write-Output "destination_drive_letter '$destination_drive_letter' does not exist" | |
exit | |
} | |
$source_path = "${source_drive_letter}:\Program Files (x86)\Steam\" | |
if (-Not (Test-Path -Path "$source_path")) | |
{ | |
Write-Output "Steam folder '$source_path' does not exist" | |
exit | |
} | |
$screenshot_folders = Get-ChildItem "$source_path" screenshots -Recurse | |
foreach ($screenshot_folder in $screenshot_folders) | |
{ | |
$screenshot_source = $screenshot_folder.FullName | |
$screenshot_dest = $screenshot_source -replace "^${source_drive_letter}", "${destination_drive_letter}" | |
Write-Output "Copying ${screenshot_source} to ${screenshot_dest}" | |
mkdir -Path "$screenshot_dest" -Force | |
Get-ChildItem -Path "$screenshot_source" -Recurse | Copy-Item -Destination "$screenshot_dest" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment