Created
May 22, 2023 12:00
-
-
Save Hashbrown777/79339a3034bc7c573716622901f55910 to your computer and use it in GitHub Desktop.
take all files in $from and put them in the same place under $to, replacing any matched files
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
$from = $from | gi | |
$to = ($to | gi).FullName | |
$from ` | |
| Get-ChildItem -File -Recurse ` | |
| &{ | |
Begin { | |
$from = '^' + [Regex]::Escape($from.FullName) | |
} | |
Process { | |
$_ ` | |
| Move-Item ` | |
-Force ` | |
-Destination ( | |
New-Item ` | |
-Force ` | |
-Type Directory ` | |
-Path ($_.Directory.FullName -replace $from,$to) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment