batch file to remove ; at each line end from txt file

June 21, 2019 at 11:39:37
Specs: Windows 10
I have a txt file which has many lines. Some of these lines end with ; Now How to have a batch file to remove from txt file
the end of line ;
Thanks

See More: batch file to remove ; at each line end from txt file

Reply ↓  Report •

#1
June 21, 2019 at 14:30:13
For speed of answer this post should be in the Programming Forum. I'll flag it up to the moderator who may be prepared to move it there for you.

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

#2
June 21, 2019 at 21:21:34
Here's something to start with, but I'm sure it will not be the final solution - there's always some complications:

@echo off & setlocal
for /f "tokens=*" %%a in (xxx) do call :aa "%%a"
goto :eof

:aa
set z=%1
set semi=%z:~-2%
if "%semi%" equ ";" (echo %z:~1,-2%) else (echo %z:~1,-1%)
::---------- end batch
not tested, and file content can work havoc with batch parsing. A sample of the file you want to "strip" would be welcome in case it has toxic content (<, >, %, &, ! etc.) Any of these chars make batch handling a nightmare and you should use a better handler, or else leave the dbl quotes for your output and handle that issue later.



Reply ↓  Report •
Related Solutions


Ask Question