这是我想要做的:
数据如下所示:
> 234.01 Burgeron/ Tom Tom Burgeron
Here is some information.
> 126.00 Waka/ Judy Judy Waka
Here is some more information.
我试图让它看起来像这样:
"234.01","Here is some information."
"126.00","Here is some more information."
这是我正在编写的批处理文件:
@ECHO off
SETLOCAL EnableDelayedExpansion
//Loop through all files in folder
for /f "tokens=*" %%a in (*) do (
CALL :GetNumber %%a
echo "!num!",%%a
) >> FILEOUTPUT.txt
//Get number on the odd-numbered lines
:GetNumber
for /f "tokens=1 delims=>" %%a in (%1) do (
set "num=%%a"
)
我在获取文件的所有其他行然后读取下一行/将其写入文件时遇到问题。我已经看到了如何跳过特定行,但没有看到如何跳过其他行。那我怎么走下一行?
这个批处理文件对我来说有点复杂。任何帮助将不胜感激。谢谢你。
显示一种交替处理行的方法:
@ECHO off
SETLOCAL EnableDelayedExpansion
REM Loop through all files in folder
for %%a in (*) do for /f "delims=" %%b in (%%a) do (
if defined num (
echo "!num!","%%b"
set "num="
) else (
for /f "tokens=1 delims=> " %%c in ("%%b") do set num=%%c
)
)
请注意,上述脚本不能驻留在包含数据文件的文件夹中,否则将作为数据进行处理。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句