powershell - remove first 3 lines and last 4 from each file
Hallo guys. I'm trying to remove first 3 lines and last 4 from all the files within the folder. Moreover some lines contains leading spaces that I want to remove.
This is what I've done:
gci c:/my_folder/ | % {
$path = $_.fullname
$file = gc $_
$file[3..($file.length-4)] | % {$_.trimstart()} | out-file $path
}
I can't under开发者_StackOverflowstand why at the end of the script ALL the files contain the same text. It seems that my variables don't change values within the script. Thanks for any help.
As I supposed I was looping always the same file. I needed to modify
$file = gc $_
in
$file = gc $_.fullname
Now everything works fine. Thanks the same :)
精彩评论