Skip to content

Instantly share code, notes, and snippets.

Last active February 14, 2022 09:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sync Steam Library to NAS / Secondary Drive using PowerShell & Robocopy
<# Source game library #>
$dir = dir "D:\Game Libraries\Steam Library\steamapps\common\" | ?{$_.PSISContainer};
<# Mapped network drive / destination path. #>
$nasPath = "G:\Steam Library\steamapps\common";
$log = "E:\gamecopy.log";
Remove-Item $log;
$dir | ForEach-Object {
Have to loop over each directory since we are using /mir.
If we rc'd the main directory it would delete games that didn't exist locally.
Set-Location $_.FullName;
# Copy options #
- /e -- Copies subdirectories. This option automatically includes empty directories.
- /zb -- Copies files in restartable mode. If file access is denied, switches to backup mode. This makes it transfer slow, like 1/100 speed.
- /j -- Copies using unbuffered I/O (recommended for large files).
- /timfix -- Fixes file times on all files, even skipped ones.
- /mir -- Mirrors a directory tree (equivalent to /e plus /purge).
- /mt:64 -- Creates multi-threaded copies with n threads. (64 Threads).
- /nooffload
# Retry options #
- /r:5 -- Specifies the number of retries on failed copies. The default value of n is 1,000,000 (one million retries).
- /w:5 -- Specifies the wait time between retries, in seconds. The default value of n is 30 (wait time 30 seconds).
- /tbd -- Specifies that the system will wait for share names to be defined (retry error 67).
# Logging options #
- /np -- Specifies that the progress of the copying operation (the number of files or directories copied so far) will not be displayed.
- /log -- No logging?
$name = $_.Name;
echo "Syncying $name";
Robocopy.exe $_.FullName "$nasPath\$name" *.* /e /j /timfix /mir /mt:128 /nooffload /r:5 /w:5 /tbd /njh /njs /ndl /nfl /np /nc /ns /log+:$log | Out-Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment