PowerShell file concatenation example.Get-content,Set-content code snippet

Posted on

Once you got how to copy one or several files, another common task is to concatenate several files from one directory and copy result to another. Find here how simple to do this with PowerShell –

   1: #PowerShell file concatenation example
   2:  
   3: # all text files from directory
   4: $source = "c:\dir\*.txt"
   5: #destination folder
   6: $dest ="d:\destination"
   7:  
   8: #adding content from all files matched files from destination directory to source file
   9:  add-content -path $dest -value (get-content $source)

 

For additional parameters see http://technet.microsoft.com/en-us/library/bb978714.aspx