Im looking for a powershell script which prompts user to select multiple files. After selection is confirmed, I want to combine all selected files into one file. Here is what I could manage so far
Function Get-FileName($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "TXT (*.txt;*.log)| *.txt;*.log"
$openFileDialog.MultiSelect = $true
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.FileNames
}
$inputfiles = Get-FileName "C:\temp"
$inputfiles
cmd /c copy /b $inputfiles out.txt
The files are usually big text/log files with millions of lines in each file and so far copy via cmd is the fastest way I know of to combine big files.
The current script copies only first file in $inputfiles
. How can I get this to work to combine all files?