Random generator for text file?

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I don't know how to ask this. I will try my best to make sense.

I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.
 
I don't know how to ask this. I will try my best to make sense.
I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.

I don't think I've ever seen an editor that randomly sorts lines.
There might well be such a utility out there somewhere though.

It would be easy to create such a utility. Email me (remove caps) if
you'd like to have it. Include your OS and the file so I can make
certain to debug correctly.
 
I don't know how to ask this. I will try my best to make sense.

I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.

It's just a text list of URLs? Something like this:

<a href="http://www.yahoo.com/">Yahoo</a>
<a href="http://www.google.com/">Google</a>
<a href="http://www.altavista.com/">Altavista</a>
<a href="http://www.obscurestore.com/">Obscure Store</a>
<a href="http://www.adaily.com/">Arts and Letters Daily</a>

or this?:

http://www.yahoo.com
http://www.google.com
http://www.altavista.com
http://www.obscurestore.com
http://www.adaily.com

Copy the following and paste it into a text editor (Notepad will do, if
you're using Windows):

<html>
<head><title>URL Mixer</title>
<style type="text/css">
textarea {width:100%}
</style>
<script type="text/javascript">
flg=1;
function mixIt(){
if(flg){
flg=0;
var f=document.forms['frm1'];
var c=(typeof parseInt(f.elements['cnt'].value=='number'))?
f.elements['cnt'].value-1:4;
var t=f.elements['txt'];
var tx=t.value.replace(/^\s+/g,'').replace(/\s+
$/g,'').split('\n');
var r=tx.length;
var l=r-1;
do{
do{
var i=Math.floor(Math.random()*r)
var tmp=tx[l];
tx[l]=tx
tx=tmp;
}while(l-->0);
l=r-1;
}while(c-->0);
t.value=tx.join('\n');
flg=1;
}
}
</script>
</head>
<body>
<form name="frm1">
Shuffle <input name="cnt" type="text" size="1" maxlength="1"
value="5" /> times<br />
<textarea rows="20" name="txt"></textarea><br />
<input type="button" value="Shuffle" onclick="mixIt()" /> <input
type="button" value="Select All" onclick="document.forms
['frm1'].elements['txt'].select()" />
</form>
</body>
</html>

Save it with an '.html' or '.htm' extension, ie, 'shuffler.html' or
'urlmixer.htm'.

Open the new file in your browser, copy and paste your URLs into the
text box, and click Shuffle. Click Select All, right-click and copy out
the rearranged URLs.
 
Michael said:
Thanks for your help! I can't seem to get this to run correctly. I click
shuffle and nothing happens.

Works fine on both my 98SE and XP Pro systems.... Make sure you've got
Javascript enabled, and have disabled any programs that disable scripting
(e.g. Norton, Script Sentry, Ad-Aware, ZoneAlarm).....

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
That works! Thank you so much! This is what I have been looking for!

Excellent. Cheers!
 
_CharlieDontSurf_, domenica 19/set/2004:
Excellent. Cheers!

Thank you also from me: I don't need that feature, but when I see these
things I think what a great group is acf! :-)
 
_CharlieDontSurf_, domenica 19/set/2004:


Thank you also from me: I don't need that feature, but when I see these
things I think what a great group is acf! :-)

That's sweet of you, Maria. Thank you.
 
CharlieDontSurf said:
I don't know how to ask this. I will try my best to make sense.

I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.


It's just a text list of URLs? Something like this:

<a href="http://www.yahoo.com/">Yahoo</a>
<a href="http://www.google.com/">Google</a>
<a href="http://www.altavista.com/">Altavista</a>
<a href="http://www.obscurestore.com/">Obscure Store</a>
<a href="http://www.adaily.com/">Arts and Letters Daily</a>

or this?:

http://www.yahoo.com
http://www.google.com
http://www.altavista.com
http://www.obscurestore.com
http://www.adaily.com

Copy the following and paste it into a text editor (Notepad will do, if
you're using Windows):

<html>
<head><title>URL Mixer</title>
<style type="text/css">
textarea {width:100%}
</style>
<script type="text/javascript">
flg=1;
function mixIt(){
if(flg){
flg=0;
var f=document.forms['frm1'];
var c=(typeof parseInt(f.elements['cnt'].value=='number'))?
f.elements['cnt'].value-1:4;
var t=f.elements['txt'];
var tx=t.value.replace(/^\s+/g,'').replace(/\s+
$/g,'').split('\n');
var r=tx.length;
var l=r-1;
do{
do{
var i=Math.floor(Math.random()*r)
var tmp=tx[l];
tx[l]=tx
tx=tmp;
}while(l-->0);
l=r-1;
}while(c-->0);
t.value=tx.join('\n');
flg=1;
}
}
</script>
</head>
<body>
<form name="frm1">
Shuffle <input name="cnt" type="text" size="1" maxlength="1"
value="5" /> times<br />
<textarea rows="20" name="txt"></textarea><br />
<input type="button" value="Shuffle" onclick="mixIt()" /> <input
type="button" value="Select All" onclick="document.forms
['frm1'].elements['txt'].select()" />
</form>
</body>
</html>

Save it with an '.html' or '.htm' extension, ie, 'shuffler.html' or
'urlmixer.htm'.

Open the new file in your browser, copy and paste your URLs into the
text box, and click Shuffle. Click Select All, right-click and copy out
the rearranged URLs.


I think your post would be a nice addition to the ACF wiki:

http://www.markcarter.me.uk/cgi-bin/wiki.pl?AcfWiki



Susan
 
CharlieDontSurf said:
I don't know how to ask this. I will try my best to make sense.

I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.

It's just a text list of URLs? Something like this:

<a href="http://www.yahoo.com/">Yahoo</a>
<a href="http://www.google.com/">Google</a>
<a href="http://www.altavista.com/">Altavista</a>
<a href="http://www.obscurestore.com/">Obscure Store</a>
<a href="http://www.adaily.com/">Arts and Letters Daily</a>

or this?:

http://www.yahoo.com
http://www.google.com
http://www.altavista.com
http://www.obscurestore.com
http://www.adaily.com

Copy the following and paste it into a text editor (Notepad will do, if
you're using Windows):

<html>
<head><title>URL Mixer</title>
<style type="text/css">
textarea {width:100%}
</style>
<script type="text/javascript">
flg=1;
function mixIt(){
if(flg){
flg=0;
var f=document.forms['frm1'];
var c=(typeof parseInt(f.elements['cnt'].value=='number'))?
f.elements['cnt'].value-1:4;
var t=f.elements['txt'];
var tx=t.value.replace(/^\s+/g,'').replace(/\s+
$/g,'').split('\n');
var r=tx.length;
var l=r-1;
do{
do{
var i=Math.floor(Math.random()*r)
var tmp=tx[l];
tx[l]=tx
tx=tmp;
}while(l-->0);
l=r-1;
}while(c-->0);
t.value=tx.join('\n');
flg=1;
}
}
</script>
</head>
<body>
<form name="frm1">
Shuffle <input name="cnt" type="text" size="1" maxlength="1"
value="5" /> times<br />
<textarea rows="20" name="txt"></textarea><br />
<input type="button" value="Shuffle" onclick="mixIt()" /> <input
type="button" value="Select All" onclick="document.forms
['frm1'].elements['txt'].select()" />
</form>
</body>
</html>

Save it with an '.html' or '.htm' extension, ie, 'shuffler.html' or
'urlmixer.htm'.

Open the new file in your browser, copy and paste your URLs into the
text box, and click Shuffle. Click Select All, right-click and copy out
the rearranged URLs.


Thanks for your help! I can't seem to get this to run correctly. I click
shuffle and nothing happens.
 
MLC said:
Thank you also from me: I don't need that feature, but when I see these
things I think what a great group is acf! :-)

Me too! Fantastic! Kudos to Charliedontsurf
Regards
brainz
 
MLC said:
_CharlieDontSurf_, domenica 19/set/2004:


Thank you also from me: I don't need that feature, but when I see these
things I think what a great group is acf! :-)

This is one of the best places on usenet. I read the messages here every
day and always find something new.
 
Michael said:
I don't know how to ask this. I will try my best to make sense.

I have a text file with a 1,000 urls in it. I'm looking for software that
can rearrange them in a random order. This way they are all mixed up and
not the way they currently are. The urls must stay intact though. Just the
order in which they are listed needs to change.

RLSort. Not quite what you asked for but it might help. This program can
take a text file and sort the lists alphabetically but reading each line
from right to left. I use it in XP to extract (say) mp3 files from a list of
URLs.
http://pweb.sophia.ac.jp/~britto/rls/ .

===

Frank Bohan
¶ Never argue with a fool -- People might not know the difference.
 
Back
Top