Simple concat based on wildcard

by Apr 13, 2011

I am writing a script that takes two parameters, sourceFile and destFile. sourceFile will include a wildcard and grab all matching text files, then concatenate them into the destFile. I thought it should be as simple as:

param([string]$sourceFile, [string]$destFile)
cat $sourceFile > $destFile

The problems I have with this are:
1) It seems to concatenate the files in a random order. I would like them to go alphabetically/numerically. test1,test2,test3 or testa,testb,testc would be concatenated in that order. I should add that files with those names actually seem to go in order, but files named File1.txt.dat, File2.txt.dat are concatenated in reverse order.
2) It adds a newline at the end of the document. I would like no blank line at the end.

How would I edit my script to resolve these two issues?