While answering a question here, I used the following code
$DataFile = Get-Item 'c:\temp\2015-01.csv'
Import-Csv -Path $DataFile -Delimiter ';' |
Measure-Object -Property 'E_TodayKwh' -Sum |
Select-Object @{label="NewName";expression={$DataFile.BaseName + '_' + $_.Sum + $DataFile.Extension}} |
Rename-Item $DataFile
This works, but I was wondering if there was a way to combine the first and second statement, while still being able to reference e.g. $DataFile.BaseName in the second statement's pipeline. I looked at -PipelineVariable, but that doesn't seem applicable here (I think?).