1: ls c:\Scripts | ? {$_.Extension -eq ".txt" } | % { @(Gc $_.fullname)[0] | ac c:\Temp\newfile.txt}
Listing all the files in the Scripts folder (LS) for all the text files. Then getting the first line and only the first line @(gc $_.fullname)[0] then piping that line to the Add-content cmdlet to build the new file. Learned that trick from Keith Hill. 8)
No comments:
Post a Comment