返回列表 发帖

[文本处理] 批处理怎样输出换行符?

真不好意思刚才发贴写清楚。我是想在批处理每个标签下插入cls.
如下修改前的代码 。
:1
语句块..
goto main
:2
语句块..
goto main
:3
语句块..
goto main
:4
语句块..
goto main
:5
语句块..
.....COPY
如修改后的代码:
:1
cls
语句块..
goto main
:2
cls
语句块..
goto main
:3
语句块..
goto main
:4
cls
语句块..
goto main
:5
cls
语句块..
.....COPY
求大侠帮下。小弟感激不尽。

@echo off
(for /l %%u in (1,1,9) do (
    for /f %%i in ('findstr ":%%u" 桌面菜单.bat') do (
        echo,%%i
        echo cls
    )
))>a.txtCOPY

TOP

我刚刚解块了不过还是要谢谢你、
公布下:
@echo off&setlocal enabledelayedexpansion
set NewLine=^
cls
for /l %%u in (1,1,9) do for /f %%i in ('findstr ":%%u" 桌面菜单.bat') do echo %%i >>a.txt && echo !NewLine! >>a.txtCOPY

TOP

3# ab362425

那个换行符没必要,因为它没有配套的回车符,在txt中无法直接显示,需要这样:
@echo off
echo  @^
@>1.txt
more 2.txt>1.txtCOPY


在win7下,也可以用wmic获取回车符:
@echo off
setlocal enabledelayedexpansion
set x0A=^
for /f %%a in ('wmic os') do set x0D=%%a
echo @!x0D!!x0A!@>1.txtCOPY

TOP

谢谢解答。

TOP

返回列表