[英]How to remove all Strings containing this?
我正在使用此代码合并所有文本文件,但是将文件名及其扩展名放在最终文件中,我想知道如何清除此问题:
Find /v "" *.txt> "Combined.txt"
文件文字:
---------- 001.TXT
abc
---------- 002.TXT
blue
123
---------- 003.TXT
abc
---------- 004.TXT
yellow
123
---------- 005.TXT
abc
---------- COMBINED.TXT
我用以下代码解决了我的问题:
Find /v "" *.txt> "Combined.txt"
Type Combined.txt | findstr /v TXT > Output.txt
del Combined.txt
ren Output.txt Combined.txt
第一行合并所有文本文件。
第二行“搜索”和“删除”行包含字符串“ TXT ”,并创建新的Output.txt文件。
第三行删除Combined.txt文件。
第四个将Output.txt重命名为Combined.txt
结果看起来像这样:
abc
blue
123
abc
yellow
123
abc
全部都是:)
del combined.txt
copy *.txt >combined.tmp
ren combined.tmp combined.txt
删除第一行以将当前的“ combined.txt”包含在最终版本中。
尝试这个:
Find/V "" *.txt|Find/V "---------- ">"Combined.txt"
…除非您的文本文件名包含十个连续的破折号和一个空格(比不包含TXT的文件名要少得多) ,否则它应该工作正常。
昨天为您提供“ Find
选项时,我将其作为an additional option which also should prepend files with their names
提供了, an additional option which also should prepend files with their names
。 还要记住,我还解释了有些选项,我也不想在结果中包括Combined.txt。
当然,您可以更改扩展名,然后将其重命名:
Find/V "" *.txt|Find/V "---------- ">"Combined.log"&&Ren "Combined.log" "Combined.txt"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.