-Batch-从单词创建字符

时间:2011-10-17 19:05:59

标签: windows batch-file cmd

我正在处理庞大的批处理文件,我需要,当用户将Hello编写为例如:

set input =
set /p input=Type hello here:

我需要从中做出 H e l l o 。 并将其保存到txt

%character_input% >hash.txt
你能帮帮我吗?感谢..

1 个答案:

答案 0 :(得分:1)

此批处理文件通过基本上按字符处理变量来输出单独行上的每个字符。这应该让你开始。 :)

@echo off

REM Get the input any way you want. Mine is hard-coded.
set input=Hello world

REM Add a terminator to prevent the loop stopping on a space
set input=%input%x

:loop

REM Extract the first character
set i=%input:~0,1%

REM Remove the first character from the input
set input=%input:~1%

REM Output the single character
echo.%i%

REM If the terminator is all that's left, terminate
if "%input%"=="x" goto done
goto :loop

:done