NEXUS-5993: Replace file.mkdir and delete where appropriate