Moudiz
Moudiz

Reputation: 7377

findstr /v removing space and dote not working

I have the below batch-file:

cd /d "T:\R\YOU"

for /r T:\R\YOU %%i in (.) do echo %%~nxi>>D:\MultiThreading\ReadFile.txt

cd /d D:\MultiThreading
rem I want to remove dots and spaces for the file content
findstr /v "." ReadFile.pbd >> 11.txt
findstr /v " " 11.pbd >> 12.txt

pause

I am getting the correct output from read file, however the output of 12.txt is empty, what I am doing wrong?

This is the output of ReadFile.txt file:

YOU
YOU 14.1.33333
YOU 14.1.44444
YOU 14.1.55555
YOU 14.1.44444

I want such output (I want to remove the first line):

YOU14133333
YOU14144444
YOU14155555
YOU14144444

Upvotes: 1

Views: 1891

Answers (2)

user6811411
user6811411

Reputation:

@Echo off
For /f "usebackq Tokens=1-10 delims=. " %%A in ("ReadFile.txt"
  ) Do If "%%B" Neq "" Echo:%%A%%B%%C%%D%%E%%F%%G%%H%%%I%%J

A bit primitive and rather short for answer.

Upvotes: 0

aschipfl
aschipfl

Reputation: 34909

The following code snippet read the file ReadFile.txt skipping the first line, removes spaces and dots from every line, and outputs the result into a file called ReturnFile.txt:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
> "ReturnFile.txt" (
    for /F "usebackq skip=1 delims=" %%L in ("ReadFile.txt") do (
        set "LINE=%%L"
        setlocal EnableDelayedExpansion
        set "LINE=!LINE: =!"
        set "LINE=!LINE:.=!"
        echo(!LINE!
        endlocal
    )
)
endlocal
exit /B

Upvotes: 1

Related Questions