Windows Batch script to pick a random section of text from a source file?
November 14, 2008 10:43 AM
Subscribe
What's the easiest way to make a Windows Batch file that will randomly choose one section from a file and copy it to a new file?
Basically, I want to be able to add sections to one file, ideally being able to put some kind of delimiter between sections, and have a Windows batch file (XP-era, if that matters) pull one of those sections out at random and place it into a separate file, replacing what was there from the last run.
Side notes:
I know "random" isn't all that random on a computer. If it's pretty close, that's fine.
I'd prefer being able to have some kind of delimiter separate them rather than have it go by line breaks, as I'd like to use line breaks inside sections.
I don't mind if I have to update the batch file to explicitly say how many sections are in the source file. If I don't have to, that'd be shiny, but it won't change often enough for me to care too much.
posted by John Kenneth Fisher to computers & internet (10 comments total)
2 users marked this as a favorite
posted by jquinby at 10:56 AM on November 14, 2008