Batch file to delete half the lines of a text file at random?

前端 未结 6 382
囚心锁ツ
囚心锁ツ 2021-01-29 11:27

I need a way to use batch to look at every line of a text file, and delete half of the lines in that text file, choosing which lines to delete at random.

This is to simu

6条回答
  •  孤独总比滥情好
    2021-01-29 12:13

    One way to do this would be to create simple files for each character. Then use a random script to do something like this:

    set/a number=%random% * (number of people there are) / 32768 + 1
    set status=dead
    call person%number%.bat   (Each file should contain a set status=live script)
    if %status% == live (
    set/a peopletokill=%peopletokill%-1
    del person%number%.bat
    )
    if %peopletokill% == 0 (
    exit
    )
    

    Something like that could work.

提交回复
热议问题