Skip to content

Instantly share code, notes, and snippets.

@ionox0
Created October 28, 2019 17:22
Show Gist options
  • Save ionox0/5865dfcd525ebf3bc7d3f43427837898 to your computer and use it in GitHub Desktop.
Save ionox0/5865dfcd525ebf3bc7d3f43427837898 to your computer and use it in GitHub Desktop.
copying a directory structure to a new dummy structure in python
# Todo: you must already be in the directory that you are trying to copy
output_location = '/some/other/place'
for (root, dirs, files) in os.walk('.'):
# Make the new directory
if not os.path.exists(os.path.join(output_location, root)):
os.mkdir(os.path.join(output_location, root))
# Make the new (empty) files
for file in files:
open(os.path.join(*[output_location, root, file]), 'a').close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment