I am using the following method to create directories but it does not work on linux if the target directory contains some of the given dirs while properly working on windows