I wrote a script this morning called “Planter.” It plants directory trees. I made a logo for it; not because it’s an official project or deserving of the extra effort, but because I had Photoshop open anyway.
Planter takes in simple, indented text files to define the structure of the directory tree it’s going to create. You pass it something like:
css
img
js
libs
mylibs
And it creates:
./css
./img
./js
./js/libs
./js/mylibs
You can nest directories as deeply as you like. You can pass the indented list to it on STDIN (piping from another command), or run planter.rb alone and it will open up your default editor and let you define the list on the fly. You can also use templates…
Create ~/.planter/ and add text files named “[template].tpl”, where “[template]” is the short name you’ll call it with. Say I have “~/.planter/client.tpl”, I can just run planter.rb client and it will read that template in and create the directory structure in whatever directory I’m in when I run it.
You can also use a very basic template variable system to add variable content. In your template, use %%X%% where X is an integer. The number corresponds to the arguments passed on the command line after the template name, so %%1%% is replaced with the first argument:
Nifty. Here’s the script. It may evolve a bit from here, but it does everything I needed it to right now. Hope it’s useful for you, too. Feel free to fork the gist and play with it.