-1

I made a Batch that fakes downloading files :

@echo off

call:set_random

:loop
call:set_random
echo %text1%
ping -n 0.5 127.0.0.1>nul
echo %text2%
ping -n 1.5 127.0.0.1>nul
goto loop

:set_random
set "rand=%random%"
set "text1=Downloading %rand%.file"
set "text2=Downloading %rand%_manager.file"

So It shows this:

Downloading 12258.file

Downloading 12258_manager.file

Downloading 445878.file

Downloading 445878_manager.file

Downloading 248712.file

Downloading 248712_manager.file etc

Further more, I would like that there is text randomly generated to transform it to this:

Downloading keyframeshow12258.file

Downloading keyframeshow12258_manager.file

Downloading menu2_445878.file

Downloading menu2_445878_manager.file

Downloading windowframe248712.file

Downloading windowframe248712_manager.file etc

Currently I got no idea how to make it do this, can someone help me? (the spaces between the non scripts are to avoid being not backspaced.)

The random words

1st words (only one):

key
image
frame
tool
gui
window
size
lua
batch
java
ping

2nd words(same):

frame
size
compatibility
time
runner
stroke
backup
wander

3rd words(same and optional):

start
truefalse
text
ref
caller
setter
looper
echoer
_onoffswitch
option
static
JosefZ
  • 28,460
  • 5
  • 44
  • 83
Cioss
  • 33
  • 7

1 Answers1

0

An easy way to do this is by making an array. Taking an axample by rojo on this post - you can select a random string from a "List". You can also make an randomizer being that if you wanted to skip 2rd words or 3rd words by the following IF OR statment bellow:

set String[0]=1
set String[1]=2

set /a "idx=%random% * 2 / 32768"

If "!String[%idx%]!"=="1" (

    Goto List2

) ELSE (

    Goto List3
)

RandomFile.bat:

@echo off
setlocal enabledelayedexpansion

:List1
set WordOne[0]=key
set WordOne[1]=image
set WordOne[2]=frame
set WordOne[3]=tool
set WordOne[4]=gui
set WordOne[5]=window
set WordOne[6]=size
set WordOne[7]=lua
set WordOne[8]=batch
set WordOne[9]=java
set WordOne[10]=ping

set /a "idx1=%random% * 11 / 32768"

:List2
set WordTwo[0]=frame
set WordTwo[1]=size
set WordTwo[2]=compatibility
set WordTwo[3]=time
set WordTwo[4]=runner
set WordTwo[5]=stroke
set WordTwo[6]=backup
set WordTwo[7]=wander

set /a "idx2=%random% * 8 / 32768"

:List3
set WordThree[0]=start
set WordThree[1]=truefalse
set WordThree[2]=text
set WordThree[3]=ref
set WordThree[4]=caller
set WordThree[5]=setter
set WordThree[6]=looper
set WordThree[7]=echoer
set WordThree[8]=_onoffswitch
set WordThree[9]=option
set WordThree[10]=static

set /a "idx3=%random% * 11 / 32768"

:Extension
set ExOne[0]=file
set ExOne[1]=cmd
set ExOne[2]=exe
set ExOne[3]=batch
set ExOne[4]=csv
set ExOne[5]=pdf
set ExOne[6]=jpg

set /a "idx4=%random% * 7 / 32768"

echo Downloading !WordOne[%idx1%]!!WordTwo[%idx2%]!%random%!WordThree[%idx3%]!.!ExOne[%idx4%]!

pause
goto List1
John Kens
  • 1,615
  • 2
  • 10
  • 28
  • 1
    Thanks for your help ! – Cioss Jan 13 '19 at 02:00
  • @Cioss If this was a solution to your post please consider accepting it so other know this is a working solution! You can do this by clicking that green check-mark! – John Kens Jan 13 '19 at 04:58
  • @GerhardBarnard I rather something that is a solution stated by the post owner be accepted no matter the awnser'iee. Isn't this what we believe in with stackoverflow - The ability to help current learners along with future students or problem solvers who want to learn? Accepting a solution lets them know in the future that there was a working solution to the current issue. Begging for rep or votes is completely different then the strive to allow future problem holders find a working solution. To `build a library of detailed answers` you first have to have answers, not corrupt arguments of rep. – John Kens Jan 13 '19 at 18:59
  • well, I believe that good answers gets rewarded with upvotes. There are still an option for others to answer a question, which might be a better answer and therefore the OP might consider chosing it as the best solution. I was just saying, soliciting of acceptace, voting is not really liked on SO. :) – Gerhard Jan 13 '19 at 19:04
  • but I will delete my comments regardless, you are being polite and I understand your point. – Gerhard Jan 13 '19 at 19:05