r/PowerShell • u/Zandizar • Nov 30 '25
Need help using Powershell or CMD to extract lines lots of txt files.
I'm in need of help getting Powershell (or CMD) to extract lines 7 and 13 from hundreds of txt files in a directory. I've been looking into options such as Get-ChildItem, Get-Content, Select-String, and ForEach-Object but I can't quite get them to do what I want. I've been experimenting with several configurations but the best I can get is the 7th from the first file and no further.
These files are in UTF-16 LE, which I know CMD doesn't like. So since PS plays nicer with them, I've been using it.
I'll have all the txt files in one directory and running it from there, so no need to direct it. I just need it to take the 7th and 13th lines from each file in the dir and Out-File it to Out.txt
Any help would be much appreciated, thank you.
View all comments
0
u/[deleted] Nov 30 '25
[deleted] — view deleted comment