Windows 从侧面到水平的批次回声
我有以下问题:一份包含此近似信息的常规列表:Windows 从侧面到水平的批次回声,windows,batch-file,scripting,Windows,Batch File,Scripting,我有以下问题:一份包含此近似信息的常规列表: Computer1 DateImplemented Computer2 DateImplemented Computer3 DateImplemented <this goes on for a while> 这将是一个50-50的方案,其中解决方案非常简单或非常困难 提前谢谢你 大概是这样的吧 @echo off setlocal enableextensions enabledelayedexpansion set LINENUM=
Computer1
DateImplemented
Computer2
DateImplemented
Computer3
DateImplemented
<this goes on for a while>
这将是一个50-50的方案,其中解决方案非常简单或非常困难
提前谢谢你 大概是这样的吧
@echo off
setlocal enableextensions enabledelayedexpansion
set LINENUM=0
set PREVLINE=
for /f "delims=" %%a in ('type list.txt') do (
set /a LINENUM+=1
set CURRLINE=%%a
set /a REMAINDER=!LINENUM! %% 2
if !REMAINDER! EQU 0 echo !PREVLINE!,!CURRLINE!
set PREVLINE=!CURRLINE!
)
endlocal
(当然,假设您的数据在list.txt中)可能是这样的吗
@echo off
setlocal enableextensions enabledelayedexpansion
set LINENUM=0
set PREVLINE=
for /f "delims=" %%a in ('type list.txt') do (
set /a LINENUM+=1
set CURRLINE=%%a
set /a REMAINDER=!LINENUM! %% 2
if !REMAINDER! EQU 0 echo !PREVLINE!,!CURRLINE!
set PREVLINE=!CURRLINE!
)
endlocal
(当然,假设您的数据在list.txt中)
通常,如果需要,可以修改此批处理页以管理特殊的批处理字符
通常,如果需要,可以修改此批处理传单以管理特殊的批处理字符。Stack Overflow是一个面向专业和热心程序员的问答网站。问题必须表现出对所解决问题的最低理解。告诉我们你试过做什么,为什么不起作用,以及它应该如何起作用。另请参阅:。Stack Overflow是一个面向专业和热心程序员的问答网站。问题必须表现出对所解决问题的最低理解。告诉我们你试过做什么,为什么不起作用,以及它应该如何起作用。另请参见:.+1,工作正常,除了惊叹号
代码>和空行,但如果需要,可以修复此问题。正确-如果输入文件包含需要转义的空行或字符,则此脚本将无法工作。PowerShell将是一个更好的选择。转义不是重点,它与模运算符一起工作,确定当前行号是奇数还是偶数。+1工作正常,除了感叹号代码>和空行,但如果需要,可以修复此问题。正确-如果输入文件包含需要转义的空行或字符,则此脚本将无法工作。PowerShell将是一个更好的选择。转义不是重点,它与模运算符一起工作,确定当前行号是奇数还是偶数。非常感谢大家。现在我终于知道该怎么做了非常感谢你们。现在我终于知道该怎么做了
@echo off
setlocal enableextensions enabledelayedexpansion
set LINENUM=0
set PREVLINE=
for /f "delims=" %%a in ('type list.txt') do (
set /a LINENUM+=1
set CURRLINE=%%a
set /a REMAINDER=!LINENUM! %% 2
if !REMAINDER! EQU 0 echo !PREVLINE!,!CURRLINE!
set PREVLINE=!CURRLINE!
)
endlocal
@echo off
setlocal EnableDelayedExpansion
set computer=
for /F "delims=" %%a in (list.txt) do (
if not defined computer (
set "computer=%%a"
) else (
echo !computer!,%%a
set computer=
)
)