使用批处理删除文本文件中的空白行和空格 [英] Removing blank lines and spaces in text file using batch

查看:157
本文介绍了使用批处理删除文本文件中的空白行和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件,正在检查注册表项的值.

I have a batch file which is checking the value of a registry key.

我让文件读取值并删除文件开头的空白行,但是输出中仍有空格需要删除.

I have the file reading the value and deleting the blank line at the beginning of the file, but there are still spaces in the output which need removing.

如果脚本包含空格,则似乎无法正确读取输出.

The script appears not to read the output properly if it contains spaces.

这是我正在使用的代码:

Here is the code I am using:

@echo off

md c:\temp
md c:\temp\Reg_Test

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SchUseStrongCrypto > c:\temp\Reg_test\AfterRegUpdate32.log

findstr /v /r /c:"^$" /c:"^\ *$" /c:"^\ *$" "C:\temp\Reg_Test\AfterRegUpdate32.log" >> "C:\temp\Reg_Test\AfterRegUpdate32.txt"

exit

除了删除空格外,它似乎可以完成我需要的所有操作.我知道这里缺少一些简单的东西.任何帮助将不胜感激.

It appears to do everything I need except for deleting the spaces. I know there is something simple I am missing here. Any help will be greatly appreciated.

推荐答案

这是您要检索的内容:

@Echo Off
MD "C:\temp\Reg_Test" 2>Nul
(For /F "EOL=H Tokens=2*" %%A In (
    'Reg Query "HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" /V "SchUseStrongCrypto" 2^>Nul'
) Do Echo %%B)>"C:\temp\Reg_Test\AfterRegUpdate32.txt"

这篇关于使用批处理删除文本文件中的空白行和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆