Skip to content

Instantly share code, notes, and snippets.

@valtoni
Created October 10, 2021 13:15
Show Gist options
  • Save valtoni/0a57bf694e41a3cfe3169d2ea569e031 to your computer and use it in GitHub Desktop.
Save valtoni/0a57bf694e41a3cfe3169d2ea569e031 to your computer and use it in GitHub Desktop.
Move founded files with structure (PowerShell)
$OldBase="C:\src\main\java"
$NewBase="C:\src\main\resources"
$HibernateFiles=Get-ChildItem $OldBase -Include *.xml -Recurse
foreach ($file in $HibernateFiles) {
Write-Host $file.FullName
$Directory=$file.Directory.ToString()
$Directory=$Directory.replace($OldBase, $NewBase)
$OldFile=$file.FullName
$NewFile=$OldFile.replace($OldBase, $NewBase)
New-Item $Directory -ItemType Directory -ea 0
Move-Item -Path $OldFile -Destination $NewFile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment