Here is my dilemma, I have been able to get the code below to search through all of the files in a directory, create new file names based on how I need them, and have even been able to get it to copy the lines of the variables $L and $zC, but I need to get all of the lines in between.
The content between can vary in length and that is why I have it set up this way, but I cannot seem to get it to grab the data. Sample data is posted below with the code underneath.
Thank you so much for all of your help and I eagerly await some expertise from those that actually know Powershell.
Sample Lines from File
¨ ,‘’“
"«
¨ +‘’› ’
"¬
© *‘’›’’
"¬
« ‘ ‘ *’’›‘’’ ‘’‘"’ ¬
’
)’‘›
’ ‘“
’’“‘” ¬
‘’
‘’
(’‘›’’ ©
''©”’
‘’‘
‘’§
(’‘›’’
©
¨©"‘’
¨ ‘•
ª¦’‘’›ª
©¦©"‘‘¦
’ “©¥’&’‘›©¨¦©"’‘¦
‘‘§
¥’%’‘‹ §¨¤
¨#’‘¤ ‘‘§£’%’‘‹ §˜¤
˜#’‘¤ ‘‘
¥¢
’$’‘Š
¥—
¢˜#’‘¢ ‘‘£ ‘#’‘Š£• –$’’
‘’
¡ž ‘#’‘‰¡”ž”%’‘ž ‘’
Ÿ›
‘"’‘ˆ
Ÿ’œ’&’‘œ ‘’
›˜
‘!’‘‡›˜’’‘˜ ‘’
–‘’ ‘‘†–Œ“Œ)’’“ ‘’
’Š=’’ ƒ!‡2Š2‡,’‘Š ‘’
C=’
“H’’= ‘“
C=’
“H’“= ‘“
C=’
‘H’“= ’
”
C=’ “H’
“> ‘•C=’–H’•> ¯C=®H¯> ®C=H®? ®C=¬HB
C=¬HB ¬C=«H¬B «C=ªH¬B ªC=©H«B ©C=¨HªB ¨C=¦H¨B ¦C=¤H§B £C=¡H¤B žC=œI B
L
D11
A2
3b840471087019604122088299
1X1100005180036B194281001001
1X1100005600041L184010
1X1100005980041L184004
1X1100006280041L170001
1X1100006130041L184001
1X1100006440041L170001
1X1100006720041L184001
1X1100006860041L184001
1X1100007000041L184001
1X1100007140041L170001
1X1100007280041L170001
1X1100007410041L184010
1X1100007640041L184001
1X1100007760041L184001
1X1100005800041L184001
1X1100006590041L170001
1Y1100000830006gfx0
Q0001
E
xCGgfx0
zC
Coding
$Folder = "c:\Scan_and_Print\" Get-ChildItem -Path $Folder -Filter *.prn | Foreach { New-Item -Path $Folder -Name "$( $_.BaseName + "_graphic" ).txt" New-Item -Path $Folder -Name "$( $_.BaseName + "_dpl" ).txt" } $PRNFiles = Get-ChildItem -Path $Folder -Filter *.prn $L = '^.L.*$' $zC = "zC" $Middle = "$L(.+?)$zC" Foreach ( $file in $PRNFiles ) { $Results = "C:\Scan_and_Print\$($file.basename + '_dpl').txt" Get-Content $file | Select-String -pattern $L, $Middle , $zC -AllMatches | Select -Expand Line | Out-File $Results -Append }