我有以下问题:一个包含以下大致信息的常规列表:
Computer1
DateImplemented
Computer2
DateImplemented
Computer3
DateImplemented
<this goes on for a while>我想要它做的是:
Computer1,DateImplemented
Computer2,DateImplemented
<etc>我已经尝试了很多方法,但我得到的唯一输出是:
Computer1
DateImplemented.这将是50-50种情况中的一种,其中解决方案是愚蠢地简单或愚蠢地困难。
提前谢谢你!
发布于 2013-07-11 05:13:07
也许是这样的吧?
@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格式的)
https://stackoverflow.com/questions/17580601
复制相似问题