3

I have several hundred files that need to be concatenated into a single file, much like this question. The problem is, that my files must must be in order. They are named with a Julian date followed by the file type.

Here's an example of the naming schema:

152_1605.old
155_0935.old
156_1535.old

etc.

This is not something I do very often and I could write my own complicated script to do this, but I feel there is a much easier way to do it and I just don't know what that way is.

  • Are these text files? – MDMoore313 Jun 6 '13 at 14:09
  • Yes, they are pipe delimited text files. – mawburn Jun 6 '13 at 14:10
6

This is a powershell two-liner:

$TextFiles = Get-Item C:\Users\sudo\Documents\MachineLists\*.list

$TextFiles | sort | foreach { Add-Content -Value $(Get-Content $_) -Path C:\users\sudo\Desktop\concat.LIST}

As you can see from the first line it helps if they're all in the same folder, which I'm sure you won't have a problem with.

  • 1
    Awesome. It seems to have worked perfectly. I really need to get more familiar with Powershell. Thanks much! – mawburn Jun 6 '13 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.