View Single Post
Old 03-09-2008   #3 (permalink)
joe.hurzeler


 
 

Re: Possible to Read only Selected lines from multiple files intoanother file deleting source files when processed?

On Mar 9, 6:43*pm, "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com>
wrote:
Quote:
Quote:

> > I need to read only the data lines from each file into a single file
> > (data.out) and delete each .in file as it has been processed.
> > I have gotten pretty close filtering by $_.Length *-gt 6, but getting
> > it into a single output file and then deleting the source file eludes
> > me.
>
Quote:

> > Is this possible and if so how?
>
Quote:

> > Your help is greatly appreciated.
>
Quote:

> > Joe
>
> Give this a try (change your paths accordingly):
>
> get-childitem c:\demo2\tmp -recurse *.in|foreach-object{
> * *select-string $_ -pattern "^dataline"|foreach-object{
> * * *add-content "c:\demo2\tmp\data.out" $_.tostring().split(":")[3]
> * *}
> * *remove-item $_.fullname -whatif
>
> }
>
> Welcome to PowerShell! ;-)
>
> It may take a more than a few hours to get your head around things, but
> its worth the ride!
>
> --
> Microsoft MVP - Windows PowerShellhttp://www.microsoft.com/mvp
>
> PowerGadgets MVPhttp://www.powergadgets.com/mvp
>
> Blog:http://marcoshaw.blogspot.com
I'm looking forward to the ride! It's been a real eye-opener so far.

Thanks for your response - intriguing!
I couldn't get it to actually put the detail line into the file
data.out until I removed '.split(":")[3]' - what does that do?

Thanks again for your help,
Joe
My System SpecsSystem Spec