G
G
Goobert Crypto2020-05-02 16:27:21
cmd/bat
Goobert Crypto, 2020-05-02 16:27:21

How to remove dashes in text document?

There is a text document rotor.txt
It contains lines with dashes


N-34;N-30A-b;N-20;

How to remove this dash with the help of a batch file and bring it to this form:
N34;N30Ab;N20;

Please help me with the code, thanks in advance)))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2020-05-02
@goober-crypto

In order to give something to compare to the res2001 answer : Decide for yourself which is harder and which is easier
Posh

(get-content old.txt -raw) -replace "-","" | set-content new.txt

embed in cmd:
powershell.exe "(get-content old.txt -raw) -replace '-','' | set-content new.txt"

R
res2001, 2020-05-02
@res2001

Now there is no Windows at hand, I did not test it.

@echo off
Setlocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in (rotor.txt) do (
   set "val=%%a"
   set "val=!val:-=!"
   >>rotor_new.txt echo.!val!
)

The code creates a new file rototr_new.txt with lines from the original file without dashes.
PS: In general, a body shirt is no more difficult to do than on a poke. The operation of replacing text in a variable is supported by the set command. Look:
set /?
for /?
setlocal /?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question