findstr / v删除空间和dote不工作

时间:2016-11-04 14:08:11

标签: 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

我从读取文件中获取正确的输出,但是12.txt的输出是空的,我做错了什么?

这是ReadFile.txt文件的输出:

YOU
YOU 14.1.33333
YOU 14.1.44444
YOU 14.1.55555
YOU 14.1.44444

我想要这样的输出(我想删除第一行):

YOU14133333
YOU14144444
YOU14155555
YOU14144444

2 个答案:

答案 0 :(得分:1)

以下代码段读取跳过第一行的文件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 的文件中:

<div class="contact">           <div class="col-md-4 contactgrid">
                <input type="text" class="text" value=" name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = ' name';}">
                </div>
                <div class="col-md-4 contactgrid">
                <input type="text" class="text" value="email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'email';}">
                </div>
                <div class="col-md-4 contactgrid">
                <input type="text" class="text" value="phone" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'phone';}">
                </div>
                <div class="col-md-8 contactgrid1">
                <textarea onfocus="if(this.value == 'Your Message') this.value='';" onblur="if(this.value == '') this.value='Your Message';" >Your Message</textarea>
                </div>
                <div class="col-md-4 contactgrid2">
                <input type="button" value="[send message]">
               </div>
               <div class="clearfix"></div>
                </div>

答案 1 :(得分:0)

@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

有点原始而且答案很简短。