added OS check, added loop and perms check for creating dirs