Batch that replaces word with random word

April 21, 2010 at 13:23:22
Specs: WINXP, core 2 duo e6320
I was needing a batch script that will replace a given word in a text file with a random generated word!
thx in advance

See More: Batch that replaces word with random word

Report •

April 21, 2010 at 14:22:31
There is a variable %random% that generates random numbers but i have never seen anything to generate random words. You would need a database of words, a method to randomly subtract a word from your database and a bit of batch magic but it would be possible with a bit of scripting.

Report •

April 21, 2010 at 14:23:26
Could u help me with a script for numbers then? thx

Report •

April 21, 2010 at 14:30:26
What exactly do you need your script to do?

Report •

Related Solutions

April 21, 2010 at 20:36:38
i made this awhile back for general-purpose:

@echo off & setlocal enabledelayedexpansion
:: demonstrating %random% string generator
:: usage: ran [length] [subset] where subset is: upper,lower,alpha,
:: alphanum, num, or all (which includes the punctuation characters)
:: if length<0 it is exact specs, if >0, it is leq specs (specs is max)
set /a max=16
set /a lc=26
set lowers=abcdefghijklmnopqrstuvwxyz
set nums=0123456789
set all= !"#$%%&'()*+,-./:;^<^=^>?@[\]^_`{|}~
set len=%1
if "%len%" equ "" set len=0
if %len% gtr %max% set len=%max%
if %len% equ 0 set len=%max%
:: disable the following if you want zero-length-word option
set /a one=1
if %len% lss 0 (set /a len=-len) else (set /a len=%random%"%%"len+one")
set chars=%2
if "%chars%" equ "" set chars=alphanum
call :%chars% %len%
echo %word%
goto :eof

set zz=%uppers%
goto :doit
set zz=%lowers%
goto :doit
set zz=%lowers%%uppers%
set /a lc*=2
goto :doit
set zz=%lowers%%uppers%%nums%
set /a lc=lc*2+10
goto :doit
set /a lc=10
set zz=%nums%
goto :doit
set zz=%lowers%%uppers%%num%%chars%
set /a lc=lc*2+10+37

set word=
for /L %%b in (1 1 !len!) do call :duh
goto :eof
set /a xx="%random%%%%lc%"
set word=!word!!zz:~%xx%,1!
::-------------- end script
to use (ie: capture), you gotta use a for-loop:

for /f "tokens=*" %%a in ('rant.bat 0 alphanum') do set xx=%%a
echo %xx%
:: ---- end
caution: if you use "all", your script might bomb!

Report •

Ask Question