skip to navigation
skip to content

Not Logged In

smash 0.1.0

A simple tool for creating full directory trees in one shot

Latest Version: 0.2.1


Smash is a simple tool for creating full directory trees in one shot. This is somewhat similar to what the mkdir unix command can do, but with an easier syntax and better usability.


Install with pip:

$ pip install smash


Smash is very easy to use. You just have to give a plain string made up of directories names and some special characters:

$ smash -p this:is+a]bunch+of:directories

and here what you get:

├── this
│   ├── is
│   └── a
├── bunch
└── of
    └── directories

The output above is going to be the directory tree generated by Smash. However, the directories are not yet created; in fact, we have specified a special -p (--preview) argument that tells Smash to show us all the directories that it could create with the given string. Remove it and smash will really create all those directories.

Now let’s take a look at the string we’ve passed as argument. You noticed the string is made up of directories names separated by one of these three special characters: :, + and ].

Let’s start with a basic example:

$ smash -p A
└── A

this will simply create a directory A inside the current directory.

What if you want to create a folder B inside the folder A?:

$ smash -p A:B
└── A
    └── B

That’s the purpose of th : character: tells Smash to create the following directories inside the previous one.

Now a little more advanced example:

$ smash -p A:B+C
└── A
    ├── B
    └── C

This will create the directories B and C inside the directory A. The + character tells Smash to create the following directory at the same lavel of the previous one.

Continuing the above example, suppose that after you type the C you need to create a folder F at the same level of the folder A. Remeber that you’ve used : to move one level down the directory tree and now you want go back one level up. That’s the situation when the ] character comes in: it tells Smash to create the following directories one level up the directory tree:

$ smash -p A:B+C]F
└── A
│   ├── B
│   └── C
└── F

To better understand these special characters you may think of them as movements up and down the directory tree, as you type.

The ] character deserves a better clarification. Although you can type it as much as you can, there is a limit to how up you can go in the directory tree and that’s the directory from where you are executing Smash.

Note: you don’t have to be in a clean directory to execute Smash but be aware that it will not overwrite any directory if it already exists. Moreover, if a folder lacks of writing permissions Smash will simply ignore the error.

I’ll go on my own

Smash by default use the characters :, + and ] as ‘movements’. They have no special meaning and are just a preference of the author. If you want to use your own preferred characters, just use the special option --movements specifying three characters separated by commas. here an example:

$ smash --movements=@,^,] a@b^c]d

Take particular care to the order of the characters. The first character will replace the : character, the second character will replace the + one and the third character will replace the ] character. If you mess up this order the result won’t be what you expected.

Be careful, there is a subtle problem with custom movements. Depending on your shell some characters carry on a special meaning and they could be interpreted by the shell and indeed break the whole directory tree.

What Smash accepts as input

Let’s see some simple rules of what you can (and cannot) pass as argument to smash:

  • you can’t pass smash a string whose leading and trailing characters are :, + or ]:

    $ smash +a:b+c    # BAD!
  • you can’t pass smash a string filled with repetitions of :, + or ] mixed together. The only exception is the ] character: Smash allows to insert any repetition of it:

    $ smash a:b+]c    # BAD!
    $ smash +a:b]]c   # OK!
  • if you provide the --movements option with your custom characters, the rules above will apply to your custom characters and not to the original ones.

Command line options

Here all the available command line options ad their meanings:

  • -p / --preview: tell Smash to show a preview of the directory tree it is going to be created with the given input.
  • -v / --verbose: tell Smash to give a feedback of what has been created and what failed.
  • --movements=<c1>,<c2>,<c3>: tell Smash to use your own movements characters.
File Type Py Version Uploaded on Size
smash-0.1.0.tar.gz (md5) Source 2012-09-22 6KB
  • Downloads (All Versions):
  • 4 downloads in the last day
  • 84 downloads in the last week
  • 280 downloads in the last month