Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
Created January 10, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidruhmann/4502966 to your computer and use it in GitHub Desktop.
Save davidruhmann/4502966 to your computer and use it in GitHub Desktop.
[Batch] Parse a file with pipe | delimiters.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
for /F "delims=" %%Z in ('type file.txt') do (
set "xLine=|%%Z"
call :Parse xLine
)
endlocal
pause >nul
goto :eof
:Parse
call set "xLine=%%%~1:||=| |%%"
for /F "tokens=1-5 delims=|" %%A in ("%xLine%") do (
echo %%A^|%%B^|%%C^|%%D^|%%E
)
goto :eof
::findstr /n ^^ file.txt
::find /v /n file.txt
::findstr ^^ file.txt
::find /v file.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment