IF you're comfortable with php, it would be quite easy to do a randomize on the file.

<?php
if ($argc > 1)
{
        ini_set('auto_detect_line_endings', true);
        $lines = file($argv[1]);
        $count = count($lines);
        while ($count > 0)
        {
                $index = rand(0, count($lines));
                echo $lines[$index];
                array_splice($lines, $index, 1);
                $count = count($lines);
        }
}
else
{
        echo 'Usage: php -f randomize.php Infile.txt'."\n";
}
?>

The php "file" function automatically works with your local file extension, reads the file 1 line per array item, then outputs them randomly including the original line ending. This script coupled with output redirection (i.e. "php -f randomize.php Input.txt > Output.txt") can do what you want very quickly.

On Jan 29, 2008, at 6:07 AM, Paul Cezanne wrote:

I needed to do this also, but for about 4,000 lines. Frankly, I just used Excel. I dropped a random number into a column, sorted on that column, and then deleted the column.

Worked like a charm.


-----Original Message-----
From: BBEdit-Talk List on behalf of After Hours
Sent: Fri 1/25/2008 11:01 AM
To: BBEdit-Talk List
Subject: Randomize lines

I have an unusual need to randomize a text file with about 500 lines
(defined by CR line endings).

Is there a method I've not discovered in BBEdit that will randomize
such a text file?

thx.

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>



--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>




--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to