steal the lovely path sanitization code from beets- there's a beer in london for whoever originally wrote that