Last active
October 19, 2025 11:36
-
-
Save s-h-a-d-o-w/395bcf40e018afafd2f39b27b5f33a79 to your computer and use it in GitHub Desktop.
The fastest way to copy a directory that I've found on Windows. Usage: "powercopy <source> <target>" - leaf directory in source will be created in target
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( | |
| [Parameter(Mandatory=$true)] | |
| [string]$source, | |
| [Parameter(Mandatory=$true)] | |
| [string]$target | |
| ) | |
| $folderName = Split-Path $source -Leaf | |
| $targetPath = Join-Path $target $folderName | |
| # Create target directory if it doesn't exist | |
| New-Item -ItemType Directory -Force -Path $targetPath | Out-Null | |
| tar -cf - -C $source . | tar -xf - -C $targetPath | |
| Write-Host "Copied $source to $targetPath" -ForegroundColor Green |
YMMV. Widely. Just did a benchmark with arbitrary files and got:
tar -cf - -C "source" . | tar -xf - -C "target"
Execution Time: 83.88 seconds
xcopy /e /y /q source target
Execution Time: 4.45 seconds
robocopy source target /E /MT:16 /NFL /NDL /NJH /NJS /NC /NS /NP
Execution Time: 1.3 seconds
On another machine, this even ran out of memory.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on the following benchmark where I copied the standalone build of a complex next.js app: