作者:5872169 | 时间:2008-08-26 18:39 | 标题:关于文字复制的问题
我有想把1.txt文件中“我爱中国”字符复制10遍到1.txt文件中,怎么实现。如:
我爱中国
我爱中国
我爱中国
我爱中国
我爱中国
我爱中国
我爱中国
我爱中国
作者:moniuming | 时间:2008-08-26 18:52
for /l
作者:flyinspace | 时间:2008-08-26 18:55
10遍太少 。1000+吧
在开始菜单里输入
cmd /c for /l %i in (1,1,1000) do echo 我爱中国>>c:\1.txt
作者:radem | 时间:2008-08-26 21:12
set/p ai=<1.txt
for /l %%a in (1,1,10) do echo.%ai%>>1.txt
作者:HAT | 时间:2008-08-26 21:20
@echo off
setlocal enabledelayedexpansion
set count=1
set /p str=<"1.txt"
:begin
>>"1.txt" echo.%str%
set /a count+=1
if !count! leq 10 goto :begin
[
Last edited by HAT on 2008-8-26 at 11:05 PM ]
作者:radem | 时间:2008-08-26 22:32
Originally posted by HAT at 2008-8-26 09:20 PM:
@echo off
setlocal enabledelayedexpansion
set count=0
set /p str=<"1.txt"
:begin
>>"1.txt" echo.%str%
set /a count+=1
if !count! leq 10 goto :begin
if !count! leq 10 goto :begin
should be:
if !count! lss 10 goto :begin
or:
if !count! leq 9 goto :begin
作者:HAT | 时间:2008-08-26 22:45 | 标题:Re 6楼
可能大家对“复制10遍”的理解不同吧。
作者:radem | 时间:2008-08-26 22:55
问题是
你的复制了11次(0-10)
加上原来的就有12个“我爱中国”啦
作者:HAT | 时间:2008-08-26 23:05 | 标题:Re 8楼
多谢指正,5楼代码已经更新。
作者:5872169 | 时间:2008-08-27 09:44
我又修改了一下
cmd /c for /l %%i in (1,1,10) do >>"c:\1.txt" @echo "我爱中国"
作者:ccily2701 | 时间:2008-08-28 14:56
set /p a=请输入你想输入的字符:
set /p b=请输入你想复制多少次:
:loop
if b==0 goto end
@echo %a% >>1.txt
set /a b-=1
goto loop
:end
pause
作者:HAT | 时间:2008-08-28 15:10
if b==0 goto end
这样能判断变量b是否等于0吗?