Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Created May 22, 2023 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hashbrown777/79339a3034bc7c573716622901f55910 to your computer and use it in GitHub Desktop.
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
$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