rewrite dir