Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Output name of file in Foreach-object command?

$
0
0

Good morning

 

I feel like I've done all the most difficult bits of this so far, but am struggling with the basics :)

 

I have a file with a date and time in seperate fields, I need to know how many rows are in the file as well as the min/max datetimes. For that I've written:

Get-ChildItem  -Filter *.csv|

Foreach-Object{

Import-Csv -path $_.Name | Select @{Name="ActualDateTime";Expression={$_."Actual Date" + " " + $_."Actual Time"}} | Measure-object ActualDateTime -min -max| Export-Csv -noTypeInformation ..\filelist.csv -append

}

 

Which is fine and outputs the following:

"Count","Average","Sum","Maximum","Minimum","Property"

"44196",,,"31/05/2013 23:59:00","01/05/2013 08:59:00","ActualDateTime"

"8406",,,"14/06/2013 04:54:00","08/06/2013 09:03:00","ActualDateTime"

etc...

But it doesn't include the filenames! As I say this feel like the easiest part of the script, but I'm totally stuck with it, possibly because I've been staring at it for too long :) Any help would be much appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles