I need help in to provide output that contain a blank space after each of 2 lines from .txt file containing number of lines without any blank in between.
Example :
Suppose a .txt file name as media.txt contains below input
A
B
C
D
.
.
.
Z
I want to represent above input into output like :
A
B
-----
C
D
----
E
F
----
.
.
.
.
I tried by using odd even concept but failing them to represent in above mentioned output.
Here, is my code in batch script:
set flag=1
for /f "tokens=2 delims==" %%a in ('type media.txt^|findstr "output"') do (
if %flag%%%2==0 (
echo %%a
) else (
echo.
echo ------------------
echo %%a
set flag+=1
)
)
Please let me know, where i am doing wrong..
This can easily be done in a batch-file or cmd with PowerShell. If you are on a supported Windows system, PowerShell will be available.
powershell -NoLogo -NoProfile -Command ^
"Get-Content .\media.txt -ReadCount 2 | ForEach-Object { $_; Write-Output '----' }"