批处理文件,用于为文本文件中的每个换行添加echo

时间:2013-04-19 22:00:17

标签: batch-file ascii echo

我正在尝试将echo添加到此文本文件中的每个新行...由于文本文件超过250000行,我认为不可能通过它并单独添加它们。有没有人在这个领域有经验,可以分享他们如何做到这一点的知识......我正在尝试用ASCII字符创建一个艺术品,直到我完成之后我才意识到我想要回应每一行...请帮助,如果你能......

来自文本文件的部分作品的例子:

......................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
............................................................::oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo:.............................................................
..........................................................::oO888888888888888888888888888888888888888888888888888888888888888888888888888OOo:...........................................................
........................................................::oO8888O8888888888OOOOOOOOOOOO888888888888OOOOO8O8OOO888888888OO888888888OOO8O8888OOo:.........................................................
......................................................::oO8888Ooo::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::oOO888OO::.......................................................
.....................................................:oO8888OO::........................................................................:oOO888OO::.....................................................
...................................................:oO88888O::............................................................................:oOO888OO::...................................................
.................................................:oO8888OO::................................................................................:oO8888Oo::.................................................
...............................................:oO8888OO::....................................................................................:oO8888Oo::...............................................
.............................................:oO88888Oo:........................................................................................:oO8888Oo::.............................................
...........................................:oO88888Oo:.................................:::::::....:::::::::::::::................................::oO8888Oo:............................................
.........................................:oO8888OOo:.............................::::ooOOOOOOo..::OOOOOOOOOOOOOOOo::::.............................::OO8888Oo:..........................................
.......................................:oOO8888Oo:...........................:::oOOOOO8888OOo:.:oO8888888888888888OOOOoo::...........................::OO8888Oo:........................................
.....................................:oOO8888Oo:..........................::oOOO888888888Oo:..::Oo:o88888888888888888888OOoo:..........................::OO8888Oo:......................................
...................................:oOO8888Oo:..........................::OO88888OO88888OO:.::OOo::o88888888888888888888888OOo::.........................::OO8888Oo:....................................

2 个答案:

答案 0 :(得分:0)

获取合理的文本编辑器,例如Notepad++,然后执行查找/替换。查找\n并将所有匹配项替换为\necho。显然有其他方法可以做到这一点,但我认为使用这样的编辑器可以毫不费力地为您提供所需的结果。

答案 1 :(得分:0)

您可以简单地使用此批次:

@ECHO OFF & setlocal
(for /f "delims=" %%i in ('findstr /n "^" ^<"artwork.txt"') do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    echo(echo(!line:*:=!
    endlocal
))>"artwork.bat"

将您的作品放在artwork.txt中,结果将显示在artwork.bat