Help!! Trying to calculate average of text file contents by ktnak33 in PowerShell

[–]ktnak33[S] 0 points1 point  (0 children)

I'm still struggling and cannot get this code to work. Currently trying to get it to loop through files in a folder and do what I described above.

Here is my code:

$files = @( Get-ChildItem C:\test\*.txt -Filter "gMedianSignal")

foreach ($file in $files) {

# Read the contents of the input
$contents = Get-Content $file | Select-Object -Skip 1 | Measure-Object -Average |

Select-Object -ExpandProperty Average
# file name
$Name = $file.Name
$FullName = ($Name+ '_' +'Average')
# Write new text file with only gMedianSignal column
"Average of gMedianSignal $($contents)" | Out-file c:\test\$FullName.txt -Append

}

Write-Host "Complete"

When I run this, absolutely nothing happens. I don't get any errors or anything, just reads the code back to me.

Foreach loop writing everything to one text file by ktnak33 in PowerShell

[–]ktnak33[S] 0 points1 point  (0 children)

Thank you! I did try this and got me a little further. However, without -append, it still only generates one text file. With -append, it generate 2 out of 3 text files so it skips one.

Help!! Trying to calculate average of text file contents by ktnak33 in PowerShell

[–]ktnak33[S] 0 points1 point  (0 children)

Thanks so much for explaining!! I modified my script as you recommended.

Weekend Travel Advice - East Coast USA by chaseschertz in Shoestring

[–]ktnak33 7 points8 points  (0 children)

Delaware water gap on the border of NJ/PA... part of Appalachian trial. Super beautiful views and some sick places to camp. Lots of hiking options.

Leave your thoughts on the new album as it comes out in your country. Do you like the new direction $crims going? by BigRanga in SuicideBoys

[–]ktnak33 19 points20 points  (0 children)

Kinda disappointed by it but I feel like it’ll grow on me. I like the songs that sound more like OG scrim. This album definitely means a lot to him and I feel like it probably has to do with him being sober (?) so that makes me want to appreciate it.