Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Windows下使用批处理文件编辑文本文件_Windows_Batch File_Cmd - Fatal编程技术网

在Windows下使用批处理文件编辑文本文件

在Windows下使用批处理文件编辑文本文件,windows,batch-file,cmd,Windows,Batch File,Cmd,我有一个关于文本文件的问题,我想用批处理文件来更改。我能把它修剪到这一点 3539 78060031 523 ) 我现在需要的是把数字排在同一行。顺便说一下,这个文本文件不是我的程序写的。我现在需要的是一些退格,直到它看起来像这样: 353978060031523 我知道有一个简单的解决方案,但因为我在脚本编写方面非常糟糕,所以我不能 找到它。 对不起,我的英语不好,帖子也不好! 这是我第一次在这里发帖。 提前谢谢。这是一个重复的问题。不过,

我有一个关于文本文件的问题,我想用批处理文件来更改。我能把它修剪到这一点

3539    
78060031              
523        )
我现在需要的是把数字排在同一行。顺便说一下,这个文本文件不是我的程序写的。我现在需要的是一些退格,直到它看起来像这样:

353978060031523
我知道有一个简单的解决方案,但因为我在脚本编写方面非常糟糕,所以我不能 找到它。 对不起,我的英语不好,帖子也不好! 这是我第一次在这里发帖。
提前谢谢。

这是一个重复的问题。不过,没关系,我只是回答你的问题。 我不知道523后面的a的用途是什么,但由于您只是连接字符串,请尝试以下脚本:


以下操作应符合您的预期,即连接数字字符并删除所有空格和字符:


此代码使用for/F的默认行为,其中选项tokens=1,delims是tab和space。

非常感谢现在看起来是这样的:3539 78060031 523我想删除空格和谢谢谢谢谢谢现在看起来是这样的:3539 78060031 523我想删除空格和谢谢
@echo off
setlocal EnableDelayedExpansion

for /f "tokens=*" %%a in (hxh-chp.txt) do (
    set "concatenate_string=!concatenate_string!%%a"
)

echo !concatenate_string!
pause >nul
setlocal EnableDelayedExpansion

for /F "usebackq" %%L in ("\path\to\your\text_file.txt") do (
    set "CONCAT=!CONCAT!%%L"
)
endlocal & set "CONCAT=%CONCAT%"
echo %CONCAT%