当前位置 主页 > 实用记录 >

    bat b.txt内容插入a.txt每一行随机位置,输出c.txt实例

    栏目:实用记录 时间:2017-12-14 22:32


    set "fa=a.txt"
    set "fb=b.txt
    set "fc=c.txt"
    echo. >"%fc%"
    echo. >"%fc%"
    (for /f "delims=" %%a in ('type "%fa%"') do (
        set /p line=
        set "str=%%a"
        set n=0
        setlocal enabledelayedexpansion
        for /l %%b in (0 1 8100) do (
            if "!str:~%%b,1!" neq "" (
                set /a n+=1
            )
        )
        set /a "m=!random! %% (n+1)"
        echo;长度!n!   随机插入位置点!m!
        for %%c in (!m!) do >>"%fc%" echo;!str:~,%%c!!line!!str:~%%c!
        endlocal
    ))<"%fb%"