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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
YMMV. Widely. Just did a benchmark with arbitrary files and got:
On another machine, this even ran out of memory.