Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created May 28, 2015 16:29
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 matt40k/59184a82609ab5b639c3 to your computer and use it in GitHub Desktop.
Save matt40k/59184a82609ab5b639c3 to your computer and use it in GitHub Desktop.
I've got a some large stored procedures that I've split up into separate files within a subfolder, this script combines them into a single file
$dir = 'C:\svn\SQL'
$dirs = Get-ChildItem -Path $dir –Directory
Foreach ($dir in $dirs) {
$files = Get-ChildItem $dir.FullName -Filter *.sql
Foreach ($file in $files) {
$combinedFile = $combinedFile + (Get-Content $file.FullName)
}
$combinedFile | Set-Content ($dir.FullName + '.sql')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment