modified run.sh to be more easily configurable

Please check that this works for you, then update run.sh if it works
This change reduces the amount of changes you need to make to run.sh every time you wish to write to a different location, and it takes care of creating the necessary subdirectories, etc.