Folks,
good day to all and every one.
Powershell newbie, as of recent.
I wanted to split a text file into smaller ones.
The file names of each text file are between placeholders
XXX File Name 1 ZZZ
some content here
XXX Filename2 ZZZ
some content here
I have been grappling with this below:confused:
http://superuser.com/questions/466363/how-to-split-a-text-file-into-multiple-text-files
# Split a Text File - By A Delimiter $Path = "C:UsersPBLDesktopb" # Folder Containing the Text file - And where Files will be Split $InputFile = (Join-Path $Path "b.txt") $Reader = New-Object System.IO.StreamReader($InputFile) While (($Line = $Reader.ReadLine()) -ne $null) { If ($Line -match " [regex]'(XXX)*(ZZZ)' { # This is wrong $OutputFile = $matches[1] + ".txt" # This is wrong } Add-Content (Join-Path $Path $OutputFile) $Line }
To summarize
The filename of each text file is between
XXX filename ZZZ – couldn’t think of anything more imaginative:rolleyes:
I want to split 1 large text file every time it finds a delimiter which is the XXX filename ZZZ
I hope I’m making more sense than last time – Ive been all over and just can’t find anything to fix it
thanks folks and RG,
really appreciative of all the help:)
pb