1.

Solve : Windows Batch/DOS - How to remove all lines from text file that end with '_' und?

Answer»

I have a file 'users.txt'. It's just a listing of usernames:

samt
robw
phil_
bill_

How can I remove all the lines that end with '_' and resave it as users.txt again using Windows Batch/DOS?

samI'd just use notepad and use the Replace ALL "_" with " " if you are TALKING about just a SINGLE TEXT file that needs to be conditioned, and you are running Windows on this system.

Then save it...ENDED up with this and it seems to work ok:

findstr /v _ users.txt > users2.txt

move /y users2.txt users.txtyou might want to match an exact _ at the end of the line in case you do really have _ all over the line.try this code
assuming the file that contail the names is q.txt

@echo off
setlocal ENABLEDELAYEDEXPANSION
for /F "" %%i in (q.txt) do (
set r=%%i
if "!r:~-1!" NEQ "_" echo %%i >>a )
move a q.txt
endlocal



Discussion

No Comment Found