Doesn't path.normalize change the slashes appropriately? It would seem better to use that instead of find and replace.