One Line: ls -r *.cs | % {(gc $_ | % { $_.TrimEnd() }) | sc $_ } Multiple Lines (same command): Get-ChildItem -Recurse *.cs | ForEach-Object { (Get-Content $_ | ForEach-Object { $_.TrimEnd() }) | Set-Content $_ } Note that we're filtering for files with a *.cs extension. To include all