Testdir script

I didn't get very far with this yet but it's a start.
Feel free to port across to python.