Even better random filenames

[Tweet : nvALT]

This is an evolution of the random filename generator I posted last week. Based on comments from BrianEnigma, this script allows you to specify “starts with” arguments to get an adjective and a noun using the WordNet dictionaries.

You can use the ready-made set I have here, or download the “Database files only” from WordNet and run this on the index.adj and index.noun files to create your libraries:

awk '{print $1}' index.adj > adjectives.txt

Edit the script below to point to the location of your dictionary files. Then just install and source it to start using. If you provide a single alphabet character as an argument, both the adjective and the noun will start with that letter. Provide two, separated by a space, and the adjective will start with the first one, the noun with the second. You can still provide no arguments to get random words from the full alphabet.


$ gen_random_filename

$ gen_random_filename a b

$ gen_random_filename z

And the script:

I’m using this with a script that generates large blocks of random lorem ipsum (based on the Lorem Ingsoc scripts) in a series of files with a Marked index file for testing Marked 2. Here’s the basic idea, just for reference. It’s truncated, but shows how to use the function above in a script:

if [[ -z $title ]]; then
	echo "Generating random title"
	title=$(gen_random_filename $start_with_1 $start_with_2)

mkdir include 2> /dev/null

echo -e "# Test Index\n\n" > $title-index.marked
jot -w "${includefile}-%d.md" - 1 $count|xargs -I % touch "%"
jot -w "${includefile}-%d.md" - 1 $count|xargs -I % echo -e "<<[%]\n" >> ${title}-index.marked