Windows 删除所有不包含句点的行

Windows 删除所有不包含句点的行,windows,batch-file,pattern-matching,substring,Windows,Batch File,Pattern Matching,Substring,我在%userprofile%\I.txt中有这样一个文本: PDF wikkipedia.ord notavalidURL snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox 我想将其转换为如下字符串: wikkipedia.ord snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox! 我只想使用本机cmd.exe语法(无powershell、cyg

我在
%userprofile%\I.txt
中有这样一个文本:

PDF

wikkipedia.ord
notavalidURL
snapfish.com
.tunnelbear.com
mail.google.com/mail/u/0/#inbox
我想将其转换为如下字符串:

wikkipedia.ord snapfish.com .tunnelbear.com mail.google.com/mail/u/0/#inbox!
我只想使用本机cmd.exe语法(无powershell、cygwin等)执行此操作

所以我知道我可以做到:

    @echo off
    setlocal EnableDelayedExpansion
    set row=
    for /f %%x in (%userprofile%\i.txt) do set "row=!row!%%x"
    echo %row% >%userprofile%\o.txt
    echo %row%
我的结果如何可以忽略所有不包含至少一个句点字符的子字符串

这将删除文件的内容:

@echo off
setlocal EnableDelayedExpansion
set row=
@For /F "EOL=|Tokens=*" %%x In ('^""%__AppDir__%find.exe" "."^<"%userprofile%\i.txt"^"') Do @Set "row=!row!%%x"
echo %row% >%userprofile%\o.txt
echo %row%
@echo关闭
setlocal EnableDelayedExpansion
排=

@对于/F“EOL=| Tokens=*”%%x In(“^”“%”%\uuuuuuu AppDir\uuuuuuuu%find.exe”。“^我已经在注释中提供了足够的信息,供您使用
find
命令更正原始方法

但是,考虑到您的示例文件内容和声明的意图,这可能足以满足您的需要:


@((对于/F“EOL=|Delims=“%%#In”(“^”“%uu AppDir_uuu%find.exe”)。^我已经在注释中提供了足够的信息,供您使用
find
命令更正原始方法

但是,考虑到您的示例文件内容和声明的意图,这可能足以满足您的需要:


@((对于/F“EOL=| Delims=“%%#In”(“^”“%%AppDir_uuuuu%find.exe”)。^只需使用内置的
find.exe
@For/F“EOL=| Tokens=*“%%”In(“^”“%%AppDir_uuuuu%find.exe”^…显然,如果批处理文件不是以
%userprofile%\desktop
作为当前目录运行,请根据需要使用
test.txt
的完整或相对路径,例如,
@For/F“EOL=| Tokens=*”%%#In(“^”“%uu AppDir_u%find.exe”)。“^为什么你抱怨没有空间,却不尝试添加它们?例如,
Do@Set”行=!行!%%x”
Do@Set”行=!行!%%x”
Do@Set”行=!行!%%x”
。如果使用某种变量,其中包含路径,请尽量记住使用quote,例如:
%path\u到\u name%\u中有空间的某些folde\u
,因为@compo已向您写入:
^此外,不要尝试读取文件内容并同时覆盖到同一文件。我建议您编写到具有不同扩展名的文件,然后对其重命名,或者将其写入未解析的目录,然后使用/Y`overwrite选项将其移动到原始位置。只需使用内置的
find.exe
@For/F“EOL=| Tokens=*”%%#in(“^”“%u AppDir_uu%find.exe”)。“^…显然,如果批处理文件不是以
%userprofile%\desktop
作为当前目录运行,请根据需要使用
test.txt
的完整或相对路径,例如,
@For/F”EOL=| Tokens=*“%%#In('^”“%uu AppDir__%find.exe”“)。“^为什么你抱怨没有空间,却不尝试添加它们?例如,
Do@Set”行=!行!%%x”
Do@Set”行=!行!%%x”
Do@Set”行=!行!%%x”
。如果使用某种变量,其中包含路径,请尽量记住使用quote,例如:
%path\u到\u name%\u中有空间的某些folde\u
,因为@compo已向您写入:
^此外,不要尝试读取文件内容并同时覆盖到同一文件。我建议您编写到具有不同扩展名的文件,然后
重命名
该文件,或者将其写入未解析的目录,然后
使用/Y`overwrite选项将其移动到原始位置。是否缺少a')“?我正在打印“ECHO is off”并保存在o.txt中您显然没有完全按照我提供的方式使用代码,问题的顶部是
%userprofile%\i.txt
内容。您应该在
%userprofile%\o.txt
wikkipedia.ord snapfish.com.tunnelbear.com mail.google.com/mail/u中获得以下内容/0/#收件箱
。是否缺少一个“)“?我正在打印“ECHO is off”并保存在o.txt中您显然没有完全按照我提供的方式使用代码,问题的顶部是
%userprofile%\i.txt
内容。您应该在
%userprofile%\o.txt
wikkipedia.ord snapfish.com.tunnelbear.com mail.google.com/mail/u中获得以下内容/0/#收件箱
@echo off
setlocal EnableDelayedExpansion
set row=
@For /F "EOL=|Tokens=*" %%x In ('^""%__AppDir__%find.exe" "."^<"%userprofile%\i.txt"^"') Do @Set "row=!row!%%x"
echo %row% >%userprofile%\o.txt
echo %row%
@echo off
setlocal EnableDelayedExpansion
set row=                                         
@For /F "EOL=|Tokens=*" %%x In ('^""%__AppDir__%find.exe" "."^<"%userprofile%\i.txt"^"') Do @Set "row=!row! %%x"
echo %row% >%userprofile%\o.txt
echo %row%